-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenopts_example2.gopts
65 lines (43 loc) · 1.39 KB
/
genopts_example2.gopts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@genopts
@program genopts_example2
@capitalize_helpusage
@version 1.2
@year 2004
@author Stanislav Brabec
@bugsto Stanislav Brabec <[email protected]>
@free_copy
@usage [OPTION]... [FILE]...
@short
Shows an example of all genopts features.
@defaults MYOPTIONS
There can be defaults stored in variable.
@switch SWI -s --switch
Shows usage of simple switch.
@cntswitch VER -v --verbose
Shows usage of countable switch.
@option VAL -d --value=VALUE
Shows usage of option with value.
@option VALD -x --dvalue=VALUE NONE
Shows usage of option with value and default.
@switch LONGO --longonly
Switches and options can be long only and short only.
Switch description can also be multi-line.
@option SHO -S=VALUE
Use this trick for defining short option with value.
@options_only
@end
# And there start our code:
echo "There is result of parsing:"
$OPTARG_SWI && echo "Simple switch was present."
$OPTARG_VER && echo "Countable verbose switch was present $OPTCNT_VER times."
$OPTARG_VAL && echo "Value option was present with value $OPTVAL_VAL."
if $OPTARG_VALD
then
echo "Dvalue option with default was present and value is $OPTVAL_VALD."
else
echo "Dvalue option with default was not present and value is $OPTVAL_VALD."
fi
$OPTARG_LONGO && echo "Long only switch was present."
$OPTARG_SHO && echo "Short value option was present with value $OPTVAL_SHO."
echo "(Non-option arguments are prohibited.)"
exit 0