#!/usr/bin/env runawk

#use "power_getopt.awk"

#.begin-str help
# power_getopt - program demonstrating a power of power_getopt.awk module
# usage: power_getopt [OPTIONS]
# OPTIONS:
#    -h|--help                  display this screen
#    -f|--flag                  flag
#       --long-flag             long flag only
#    -s                         short flag only
#    =F|--FLAG <value>          flag with value
#       =-LONG-FLAG <value>     long flag with value
#    =S <value>                 short flag with value
#    -X                         short flag
#    =Y <value>                 short flag with value
#    -P                         print ARGC and ARGV
#.end-str

# Very powerful easy for use module for handling options

BEGIN {
	if (getarg("P")){
		print "ARGC=" ARGC
		for (i=1; i < ARGC; ++i){
			printf "ARGV [%d]=%s\n", i, ARGV [i]
		}
		exit (0)
	}

	print "The following option were applied"
	for (i in options){
		print "options [" i "]=" options [i]
	}
	print "f         --- " getarg("f")
	print "flag      --- " getarg("flag")
	print "long-flag --- " getarg("long-flag")
	print "s         --- " getarg("s")
	print "F         --- " getarg("F", "default1")
	print "FLAG      --- " getarg("FLAG", "default2")
	print "LONG-FLAG --- " getarg("LONG-FLAG", "default3")
	print "S         --- " getarg("S", "default4")
	print "X         --- " getarg("X")
	print "Y         --- " getarg("Y", "default5")


	exit 0
}
