You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/ArgumentParser/Completions/FishCompletionsGenerator.swift
+52-19Lines changed: 52 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -24,20 +24,36 @@ extension ToolInfoV0 {
24
24
extensionCommandInfoV0{
25
25
fileprivatevarfishCompletionScript:String{
26
26
"""
27
-
function \(shouldOfferCompletionsForFunctionName) -a expected_commands expected_positional_index positional_index_comparison
28
-
set -l unparsed_tokens (\(tokensFunctionName) -pc)
27
+
function \(shouldOfferCompletionsForFlagsOrOptionsFunctionName) -a expected_commands
28
+
set -l non_repeating_flags_or_options $argv[2..]
29
+
30
+
set -l non_repeating_flags_or_options_absent 0
29
31
set -l positional_index 0
30
32
set -l commands
33
+
\(parseTokensFunctionName)
34
+
test "$commands" = "$expected_commands"; and return $non_repeating_flags_or_options_absent
35
+
end
31
36
37
+
function \(shouldOfferCompletionsForPositionalFunctionName) -a expected_commands expected_positional_index positional_index_comparison
32
38
if test -z $positional_index_comparison
33
39
set positional_index_comparison -eq
34
40
end
35
41
42
+
set -l non_repeating_flags_or_options
43
+
set -l non_repeating_flags_or_options_absent 0
44
+
set -l positional_index 0
45
+
set -l commands
46
+
\(parseTokensFunctionName)
47
+
test "$commands" = "$expected_commands" -a \\( "$positional_index""$positional_index_comparison""$expected_positional_index"\\)
48
+
end
49
+
50
+
function \(parseTokensFunctionName) -S
51
+
set -l unparsed_tokens (\(tokensFunctionName) -pc)
52
+
set -l present_flags_and_options
53
+
36
54
switch $unparsed_tokens[1]
37
55
\(commandCases)
38
56
end
39
-
40
-
test "$commands" = "$expected_commands" -a \\( -z "$expected_positional_index" -o "$positional_index""$positional_index_comparison""$expected_positional_index"\\)
41
57
end
42
58
43
59
function \(tokensFunctionName)
@@ -48,9 +64,8 @@ extension CommandInfoV0 {
48
64
end
49
65
end
50
66
51
-
function \(parseSubcommandFunctionName) -S
67
+
function \(parseSubcommandFunctionName) -S -a positional_count
complete -c 'math' -n '__math_should_offer_completions_for"math stats" 1' -fa 'average' -d 'Print the average of the values.'
100
-
complete -c 'math' -n '__math_should_offer_completions_for"math stats" 1' -fa 'stdev' -d 'Print the standard deviation of the values.'
101
-
complete -c 'math' -n '__math_should_offer_completions_for"math stats" 1' -fa 'quantiles' -d 'Print the quantiles of the values (TBD).'
102
-
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_flags_or_options"math stats" h help' -s 'h' -l 'help' -d 'Show help information.'
122
+
complete -c 'math' -n '__math_should_offer_completions_for_positional"math stats" 1' -fa 'average' -d 'Print the average of the values.'
123
+
complete -c 'math' -n '__math_should_offer_completions_for_positional"math stats" 1' -fa 'stdev' -d 'Print the standard deviation of the values.'
124
+
complete -c 'math' -n '__math_should_offer_completions_for_positional"math stats" 1' -fa 'quantiles' -d 'Print the quantiles of the values (TBD).'
125
+
complete -c 'math' -n '__math_should_offer_completions_for_flags_or_options"math stats average" kind' -l 'kind' -d 'The kind of average to provide.' -rfka 'mean median mode'
0 commit comments