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
A generated fish script didn't complete an option after an argument.
The cause is the generated fish script doesn't accept an input text which already has arguments.
For example, when the input is `repeat -`, the script can complete `--count`, but when the text is `repeat foo -`, the script cannot complete `repeat foo --count`, because the input text already has the argument "foo".
To fix the issue, `FishCompletionsGenerator` got a capability that can accept a text which has arguments.
Copy file name to clipboardExpand all lines: Tests/ArgumentParserExampleTests/MathExampleTests.swift
+53-33Lines changed: 53 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -545,45 +545,65 @@ _math
545
545
"""
546
546
547
547
privateletfishCompletionScriptText="""
548
+
# A function which filters options which starts with \"-\" from $argv.
549
+
function _swift_math_preprocessor
550
+
set -l results
551
+
for i in (seq (count $argv))
552
+
switch (echo $argv[$i] | string sub -l 1)
553
+
case '-'
554
+
case '*'
555
+
echo $argv[$i]
556
+
end
557
+
end
558
+
end
559
+
548
560
function _swift_math_using_command
549
-
set -l cmd (commandline -opc)
550
-
if [ (count $cmd) -eq (count $argv) ]
551
-
for i in (seq (count $argv))
552
-
if [ $cmd[$i] != $argv[$i] ]
561
+
set -l currentCommands (_swift_math_preprocessor (commandline -opc))
562
+
set -l expectedCommands (string split \"\" $argv[1])
563
+
set -l subcommands (string split \"\" $argv[2])
564
+
if [ (count $currentCommands) -ge (count $expectedCommands) ]
565
+
for i in (seq (count $expectedCommands))
566
+
if [ $currentCommands[$i] != $expectedCommands[$i] ]
553
567
return 1
554
568
end
555
569
end
570
+
if [ (count $currentCommands) -eq (count $expectedCommands) ]
571
+
return 0
572
+
end
573
+
if [ (count $subcommands) -gt 1 ]
574
+
for i in (seq (count $subcommands))
575
+
if [ $currentCommands[(math (count $expectedCommands) + 1)] = $subcommands[$i] ]
576
+
return 1
577
+
end
578
+
end
579
+
end
556
580
return 0
557
581
end
558
582
return 1
559
583
end
560
-
complete -c math -n '_swift_math_using_command math' -f -l version -d 'Show the version.'
561
-
complete -c math -n '_swift_math_using_command math' -f -s h -l help -d 'Show help information.'
562
-
complete -c math -n '_swift_math_using_command math' -f -a 'add' -d 'Print the sum of the values.'
563
-
complete -c math -n '_swift_math_using_command math' -f -a 'multiply' -d 'Print the product of the values.'
564
-
complete -c math -n '_swift_math_using_command math' -f -a 'stats' -d 'Calculate descriptive statistics.'
565
-
complete -c math -n '_swift_math_using_command math' -f -a 'help' -d 'Show subcommand help information.'
566
-
complete -c math -n '_swift_math_using_command math add' -f -l hex-output -s x -d 'Use hexadecimal notation for the result.'
567
-
complete -c math -n '_swift_math_using_command math add' -f -s h -l help -d 'Show help information.'
568
-
complete -c math -n '_swift_math_using_command math multiply' -f -l hex-output -s x -d 'Use hexadecimal notation for the result.'
569
-
complete -c math -n '_swift_math_using_command math multiply' -f -s h -l help -d 'Show help information.'
570
-
complete -c math -n '_swift_math_using_command math stats' -f -s h -l help -d 'Show help information.'
571
-
complete -c math -n '_swift_math_using_command math stats' -f -a 'average' -d 'Print the average of the values.'
572
-
complete -c math -n '_swift_math_using_command math stats' -f -a 'stdev' -d 'Print the standard deviation of the values.'
573
-
complete -c math -n '_swift_math_using_command math stats' -f -a 'quantiles' -d 'Print the quantiles of the values (TBD).'
574
-
complete -c math -n '_swift_math_using_command math stats' -f -a 'help' -d 'Show subcommand help information.'
575
-
complete -c math -n '_swift_math_using_command math stats average' -f -r -l kind -d 'The kind of average to provide.'
576
-
complete -c math -n '_swift_math_using_command math stats average --kind' -f -k -a 'mean median mode'
577
-
complete -c math -n '_swift_math_using_command math stats average' -f -l version -d 'Show the version.'
578
-
complete -c math -n '_swift_math_using_command math stats average' -f -s h -l help -d 'Show help information.'
579
-
complete -c math -n '_swift_math_using_command math stats stdev' -f -s h -l help -d 'Show help information.'
580
-
complete -c math -n '_swift_math_using_command math stats quantiles' -f -r -l file
581
-
complete -c math -n '_swift_math_using_command math stats quantiles --file' -f -a '(for i in *.{txt,md}; echo $i;end)'
582
-
complete -c math -n '_swift_math_using_command math stats quantiles' -f -r -l directory
583
-
complete -c math -n '_swift_math_using_command math stats quantiles --directory' -f -a '(__fish_complete_directories)'
584
-
complete -c math -n '_swift_math_using_command math stats quantiles' -f -r -l shell
585
-
complete -c math -n '_swift_math_using_command math stats quantiles --shell' -f -a '(head -100 /usr/share/dict/words | tail -50)'
586
-
complete -c math -n '_swift_math_using_command math stats quantiles' -f -r -l custom
587
-
complete -c math -n '_swift_math_using_command math stats quantiles --custom' -f -a '(command math ---completion stats quantiles -- --custom (commandline -opc)[1..-1])'
588
-
complete -c math -n '_swift_math_using_command math stats quantiles' -f -s h -l help -d 'Show help information.'
584
+
585
+
complete -c math -n \'_swift_math_using_command \"math add\"\' -l hex-output -s x -d \'Use hexadecimal notation for the result.\'
586
+
complete -c math -n \'_swift_math_using_command \"math add\"\' -s h -l help -d \'Show help information.\'
587
+
complete -c math -n \'_swift_math_using_command \"math multiply\"\' -l hex-output -s x -d \'Use hexadecimal notation for the result.\'
588
+
complete -c math -n \'_swift_math_using_command \"math multiply\"\' -s h -l help -d \'Show help information.\'
589
+
complete -c math -n \'_swift_math_using_command \"math stats average\"\' -l kind -d \'The kind of average to provide.\' -r -f -k -a \'mean median mode\'
590
+
complete -c math -n \'_swift_math_using_command \"math stats average\"\' -l version -d \'Show the version.\'
591
+
complete -c math -n \'_swift_math_using_command \"math stats average\"\' -s h -l help -d \'Show help information.\'
592
+
complete -c math -n \'_swift_math_using_command \"math stats stdev\"\' -s h -l help -d \'Show help information.\'
593
+
complete -c math -n \'_swift_math_using_command \"math stats quantiles\"\' -l file -r -f -a \'(for i in *.{txt,md}; echo $i;end)\'
594
+
complete -c math -n \'_swift_math_using_command \"math stats quantiles\"\' -l directory -r -f -a \'(__fish_complete_directories)\'
595
+
complete -c math -n \'_swift_math_using_command \"math stats quantiles\"\' -l shell -r -f -a \'(head -100 /usr/share/dict/words | tail -50)\'
596
+
complete -c math -n \'_swift_math_using_command \"math stats quantiles\"\' -l custom -r -f -a \'(command math ---completion stats quantiles -- --custom (commandline -opc)[1..-1])\'
597
+
complete -c math -n \'_swift_math_using_command \"math stats quantiles\"\' -s h -l help -d \'Show help information.\'
598
+
complete -c math -n \'_swift_math_using_command \"math stats\"\"average stdev quantiles help\"\' -s h -l help -d \'Show help information.\'
599
+
complete -c math -n \'_swift_math_using_command \"math stats\"\"average stdev quantiles help\"\' -f -a \'average\' -d \'Print the average of the values.\'
600
+
complete -c math -n \'_swift_math_using_command \"math stats\"\"average stdev quantiles help\"\' -f -a \'stdev\' -d \'Print the standard deviation of the values.\'
601
+
complete -c math -n \'_swift_math_using_command \"math stats\"\"average stdev quantiles help\"\' -f -a \'quantiles\' -d \'Print the quantiles of the values (TBD).\'
602
+
complete -c math -n \'_swift_math_using_command \"math stats\"\"average stdev quantiles help\"\' -f -a \'help\' -d \'Show subcommand help information.\'
603
+
complete -c math -n \'_swift_math_using_command \"math\"\"add multiply stats help\"\' -l version -d \'Show the version.\'
604
+
complete -c math -n \'_swift_math_using_command \"math\"\"add multiply stats help\"\' -s h -l help -d \'Show help information.\'
605
+
complete -c math -n \'_swift_math_using_command \"math\"\"add multiply stats help\"\' -f -a \'add\' -d \'Print the sum of the values.\'
606
+
complete -c math -n \'_swift_math_using_command \"math\"\"add multiply stats help\"\' -f -a \'multiply\' -d \'Print the product of the values.\'
607
+
complete -c math -n \'_swift_math_using_command \"math\"\"add multiply stats help\"\' -f -a \'stats\' -d \'Calculate descriptive statistics.\'
608
+
complete -c math -n \'_swift_math_using_command \"math\"\"add multiply stats help\"\' -f -a \'help\' -d \'Show subcommand help information.\'
0 commit comments