-
Notifications
You must be signed in to change notification settings - Fork 1
/
example-auto.sh
executable file
·78 lines (62 loc) · 1.49 KB
/
example-auto.sh
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
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Load the Wonderful Argument Parser library
. wap.sh
_fn_help="Some basic functions"
fn_req(){ ## <a> <b>: Basic Required args
wap_help <<-EOF
required
EOF
# This is a debug function to show you what variables are set.
# You can just use the arguments named $arg_a and $arg_b
# to access the values passed in.
wap_debug_available_args
}
fn_flag(){ ## [--flag]: Quick and easy
wap_help <<-EOF
flag (bool)
EOF
wap_debug_available_args
}
fn_flag_val(){ ## [--a=<interval>] [--b=<user_id>]: Does something more
wap_help <<-EOF
flag (with a value, no default)
EOF
wap_debug_available_args
}
fn_flag_val_default(){ ## [--flag=2]: A default now
wap_help <<-EOF
flag (val, default)
EOF
wap_debug_available_args
}
fn_optional(){ ## [optional]: A completely optional thing
wap_help <<-EOF
optional
EOF
wap_debug_available_args
}
fn_optional_default(){ ## [wetness=9]: A completely optional thing with a default value
wap_help <<-EOF
optional
EOF
wap_debug_available_args
}
_group_help="More Advanced"
group_1(){ ## <x> <y|z> [user|email|id] [--a] [--b=] [--c=1]: Fancy!
wap_help <<-EOF
Documentation for fn1, it does lots of things!
EOF
wap_debug_available_args
}
group_2(){ ## <x> <y|z> [user|email|id] [--a] [--b=] [--c=1]: The same!
wap_help <<-EOF
Documentation for fn1, it does lots of things!
EOF
wap_debug_available_args
}
# Discover functions, handle unknown functions, help, etc.
if (( WAP_SUBCOMMANDS == 1 )); then
wapify_subcommands $@
else
wapify $@
fi