-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.fish
More file actions
executable file
·40 lines (39 loc) · 967 Bytes
/
example.fish
File metadata and controls
executable file
·40 lines (39 loc) · 967 Bytes
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
#!/usr/bin/env fish
make || exit
set spec 'flags: f,flag=-g=-h g=-h=-qwerty qwerty=-flag=-h=-g h,help; parameters: q,asdf u=defval nothing zzz,z,Z=someth; positionals: asdf test;'
set helpmsg '
help = print this help message
flag = a random flag
g = i dunno, its nonsense
qwerty = a keyboard layout
asdf = q param
u = something
zzz = a bunch of zs
'
# print out the raw output
echo raw output:
set vars "$(echo $spec | ./clparser -e --help-msg $helpmsg -- $argv)"
set ec $status
echo $vars
if test $ec != 0
echo exit code: $ec
exit $ec
end
# actually run it and show results
echo variable results:
eval "$vars"
echo f,flag = "$flag"
echo g = "$g"
echo qwerty = "$qwerty"
echo h,help = "$help"
echo q,asdf = "$asdf"
echo u = "$u"
echo nothing = "$nothing"
echo zzz,z,Z = "$Z"
echo positional params:
echo asdf = "$asdf"
echo test = "$test"
#printf 'positional args: %s\n' "$*"
printf 'positional args:'
printf " '%s'" $args
printf '\n'