-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathtestMathFishCompletionScript().fish
More file actions
112 lines (101 loc) · 7.17 KB
/
testMathFishCompletionScript().fish
File metadata and controls
112 lines (101 loc) · 7.17 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
function __math_should_offer_completions_for -a expected_commands -a expected_positional_index
set -l unparsed_tokens (__math_tokens -pc)
set -l positional_index 0
set -l commands
switch $unparsed_tokens[1]
case 'math'
__math_parse_subcommand 0 'version' 'h/help'
switch $unparsed_tokens[1]
case 'add'
__math_parse_subcommand -r 1 'x/hex-output' 'version' 'h/help'
case 'multiply'
__math_parse_subcommand -r 1 'x/hex-output' 'version' 'h/help'
case 'stats'
__math_parse_subcommand 0 'version' 'h/help'
switch $unparsed_tokens[1]
case 'average'
__math_parse_subcommand -r 1 'kind=' 'version' 'h/help'
case 'stdev'
__math_parse_subcommand -r 1 'version' 'h/help'
case 'quantiles'
__math_parse_subcommand -r 1 'file=' 'one-of-four=' 'custom-arg=' 'custom-deprecated-arg=' 'shell=' 'custom=' 'custom-deprecated=' 'version' 'h/help'
end
case 'help'
__math_parse_subcommand -r 1 'version'
end
end
test "$commands" = "$expected_commands" -a \( -z "$expected_positional_index" -o "$expected_positional_index" -eq "$positional_index" \)
end
function __math_tokens
if test (string split -m 1 -f 1 -- . "$FISH_VERSION") -gt 3
commandline --tokens-raw $argv
else
commandline -o $argv
end
end
function __math_parse_subcommand -S
argparse -s r -- $argv
set -l positional_count $argv[1]
set -l option_specs $argv[2..]
set -a commands $unparsed_tokens[1]
set -e unparsed_tokens[1]
set positional_index 0
while true
argparse -sn "$commands" $option_specs -- $unparsed_tokens 2> /dev/null
set unparsed_tokens $argv
set positional_index (math $positional_index + 1)
if test (count $unparsed_tokens) -eq 0 -o \( -z "$_flag_r" -a "$positional_index" -gt "$positional_count" \)
return 0
end
set -e unparsed_tokens[1]
end
end
function __math_complete_directories
set -l token (commandline -t)
string match -- '*/' $token
set -l subdirs $token*/
printf '%s\n' $subdirs
end
function __math_custom_completion
set -x SAP_SHELL fish
set -x SAP_SHELL_VERSION $FISH_VERSION
set -l tokens (__math_tokens -p)
if test -z (__math_tokens -t)
set -l index (count (__math_tokens -pc))
set tokens $tokens[..$index] \'\' $tokens[(math $index + 1)..]
end
command $tokens[1] $argv $tokens
end
complete -c 'math' -f
complete -c 'math' -n '__math_should_offer_completions_for "math"' -l 'version' -d 'Show the version.'
complete -c 'math' -n '__math_should_offer_completions_for "math"' -s 'h' -l 'help' -d 'Show help information.'
complete -c 'math' -n '__math_should_offer_completions_for "math" 1' -fa 'add' -d 'Print the sum of the values.'
complete -c 'math' -n '__math_should_offer_completions_for "math" 1' -fa 'multiply' -d 'Print the product of the values.'
complete -c 'math' -n '__math_should_offer_completions_for "math" 1' -fa 'stats' -d 'Calculate descriptive statistics.'
complete -c 'math' -n '__math_should_offer_completions_for "math" 1' -fa 'help' -d 'Show subcommand help information.'
complete -c 'math' -n '__math_should_offer_completions_for "math add"' -l 'hex-output' -s 'x' -d 'Use hexadecimal notation for the result.'
complete -c 'math' -n '__math_should_offer_completions_for "math add"' -l 'version' -d 'Show the version.'
complete -c 'math' -n '__math_should_offer_completions_for "math add"' -s 'h' -l 'help' -d 'Show help information.'
complete -c 'math' -n '__math_should_offer_completions_for "math multiply"' -l 'hex-output' -s 'x' -d 'Use hexadecimal notation for the result.'
complete -c 'math' -n '__math_should_offer_completions_for "math multiply"' -l 'version' -d 'Show the version.'
complete -c 'math' -n '__math_should_offer_completions_for "math multiply"' -s 'h' -l 'help' -d 'Show help information.'
complete -c 'math' -n '__math_should_offer_completions_for "math stats"' -l 'version' -d 'Show the version.'
complete -c 'math' -n '__math_should_offer_completions_for "math stats"' -s 'h' -l 'help' -d 'Show help information.'
complete -c 'math' -n '__math_should_offer_completions_for "math stats" 1' -fa 'average' -d 'Print the average of the values.'
complete -c 'math' -n '__math_should_offer_completions_for "math stats" 1' -fa 'stdev' -d 'Print the standard deviation of the values.'
complete -c 'math' -n '__math_should_offer_completions_for "math stats" 1' -fa 'quantiles' -d 'Print the quantiles of the values (TBD).'
complete -c 'math' -n '__math_should_offer_completions_for "math stats average"' -l 'kind' -d 'The kind of average to provide.' -rfka 'mean median mode'
complete -c 'math' -n '__math_should_offer_completions_for "math stats average"' -l 'version' -d 'Show the version.'
complete -c 'math' -n '__math_should_offer_completions_for "math stats average"' -s 'h' -l 'help' -d 'Show help information.'
complete -c 'math' -n '__math_should_offer_completions_for "math stats stdev"' -l 'version' -d 'Show the version.'
complete -c 'math' -n '__math_should_offer_completions_for "math stats stdev"' -s 'h' -l 'help' -d 'Show help information.'
complete -c 'math' -n '__math_should_offer_completions_for "math stats quantiles"' -l 'file' -d 'Input file or directory to process (default section).' -rfa '(set -l exts \'txt\' \'md\';for p in (string match -e -- \'*/\' (commandline -t);or printf \n)*.{$exts};printf %s\n $p;end;__fish_complete_directories (commandline -t) \'\')'
complete -c 'math' -n '__math_should_offer_completions_for "math stats quantiles"' -l 'one-of-four' -d 'Choose one of four predefined options' -rfka 'alphabet alligator branch braggart'
complete -c 'math' -n '__math_should_offer_completions_for "math stats quantiles"' -l 'custom-arg' -d 'Custom argument' -rfka '(__math_custom_completion ---completion stats quantiles -- --custom-arg (count (__math_tokens -pc)) (__math_tokens -tC))'
complete -c 'math' -n '__math_should_offer_completions_for "math stats quantiles"' -l 'custom-deprecated-arg' -d 'Deprecated custom argument' -rfka '(__math_custom_completion ---completion stats quantiles -- --custom-deprecated-arg)'
complete -c 'math' -n '__math_should_offer_completions_for "math stats quantiles"' -l 'shell' -d 'Run a shell command for input or completion' -rfka '(head -100 /usr/share/dict/words | tail -50)'
complete -c 'math' -n '__math_should_offer_completions_for "math stats quantiles"' -l 'custom' -d 'Custom user-provided option with dynamic completion' -rfka '(__math_custom_completion ---completion stats quantiles -- --custom (count (__math_tokens -pc)) (__math_tokens -tC))'
complete -c 'math' -n '__math_should_offer_completions_for "math stats quantiles"' -l 'custom-deprecated' -d 'Deprecated custom option' -rfka '(__math_custom_completion ---completion stats quantiles -- --custom-deprecated)'
complete -c 'math' -n '__math_should_offer_completions_for "math stats quantiles"' -l 'version' -d 'Show the version.'
complete -c 'math' -n '__math_should_offer_completions_for "math stats quantiles"' -s 'h' -l 'help' -d 'Show help information.'
complete -c 'math' -n '__math_should_offer_completions_for "math help"' -l 'version' -d 'Show the version.'