Skip to content

Commit dc75888

Browse files
committed
Backwards compatibility in fish completion scripts with fish 3.3.x-
Change set -f to set -l. Replace $(…) with (…) command substitutions. Signed-off-by: Ross Goldberg <[email protected]>
1 parent 33dd0d6 commit dc75888

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

Sources/ArgumentParser/Completions/FishCompletionsGenerator.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ extension [ParsableCommand.Type] {
1818
let commandName = first!._commandName
1919
return """
2020
function \(shouldOfferCompletionsForFunctionName) -a expected_commands -a expected_positional_index
21-
set -f unparsed_tokens (\(tokensFunctionName) -pc)
22-
set -f positional_index 0
23-
set -f commands
21+
set -l unparsed_tokens (\(tokensFunctionName) -pc)
22+
set -l positional_index 0
23+
set -l commands
2424
2525
switch $unparsed_tokens[1]
2626
\(commandCases)
@@ -30,7 +30,7 @@ extension [ParsableCommand.Type] {
3030
end
3131
3232
function \(tokensFunctionName)
33-
if test "$(string split -m 1 -f 1 -- . "$FISH_VERSION")" -gt 3
33+
if test (string split -m 1 -f 1 -- . "$FISH_VERSION") -gt 3
3434
commandline --tokens-raw $argv
3535
else
3636
commandline -o $argv
@@ -39,8 +39,8 @@ extension [ParsableCommand.Type] {
3939
4040
function \(parseSubcommandFunctionName) -S
4141
argparse -s r -- $argv
42-
set -f positional_count $argv[1]
43-
set -f option_specs $argv[2..]
42+
set -l positional_count $argv[1]
43+
set -l option_specs $argv[2..]
4444
4545
set -a commands $unparsed_tokens[1]
4646
set -e unparsed_tokens[1]
@@ -59,20 +59,20 @@ extension [ParsableCommand.Type] {
5959
end
6060
6161
function \(completeDirectoriesFunctionName)
62-
set -f token (commandline -t)
62+
set -l token (commandline -t)
6363
string match -- '*/' $token
64-
set -f subdirs $token*/
64+
set -l subdirs $token*/
6565
printf '%s\\n' $subdirs
6666
end
6767
6868
function \(customCompletionFunctionName)
6969
set -x \(CompletionShell.shellEnvironmentVariableName) fish
7070
set -x \(CompletionShell.shellVersionEnvironmentVariableName) $FISH_VERSION
7171
72-
set -f tokens (\(tokensFunctionName) -p)
73-
if test -z "$(\(tokensFunctionName) -t)"
74-
set -f index (count (\(tokensFunctionName) -pc))
75-
set -f tokens $tokens[..$index] \\'\\' $tokens[$(math $index + 1)..]
72+
set -l tokens (\(tokensFunctionName) -p)
73+
if test -z (\(tokensFunctionName) -t)
74+
set -l index (count (\(tokensFunctionName) -pc))
75+
set tokens $tokens[..$index] \\'\\' $tokens[(math $index + 1)..]
7676
end
7777
command $tokens[1] $argv $tokens
7878
end

Tests/ArgumentParserExampleTests/Snapshots/testMathFishCompletionScript().fish

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function _swift_math_should_offer_completions_for -a expected_commands -a expected_positional_index
2-
set -f unparsed_tokens (_swift_math_tokens -pc)
3-
set -f positional_index 0
4-
set -f commands
2+
set -l unparsed_tokens (_swift_math_tokens -pc)
3+
set -l positional_index 0
4+
set -l commands
55

66
switch $unparsed_tokens[1]
77
case 'math'
@@ -39,8 +39,8 @@ end
3939

4040
function _swift_math_parse_subcommand -S
4141
argparse -s r -- $argv
42-
set -f positional_count $argv[1]
43-
set -f option_specs $argv[2..]
42+
set -l positional_count $argv[1]
43+
set -l option_specs $argv[2..]
4444

4545
set -a commands $unparsed_tokens[1]
4646
set -e unparsed_tokens[1]
@@ -59,20 +59,20 @@ function _swift_math_parse_subcommand -S
5959
end
6060

6161
function _swift_math_complete_directories
62-
set -f token (commandline -t)
62+
set -l token (commandline -t)
6363
string match -- '*/' $token
64-
set -f subdirs $token*/
64+
set -l subdirs $token*/
6565
printf '%s\n' $subdirs
6666
end
6767

6868
function _swift_math_custom_completion
6969
set -x SAP_SHELL fish
7070
set -x SAP_SHELL_VERSION $FISH_VERSION
7171

72-
set -f tokens (_swift_math_tokens -p)
72+
set -l tokens (_swift_math_tokens -p)
7373
if test -z "$(_swift_math_tokens -t)"
74-
set -f index (count (_swift_math_tokens -pc))
75-
set -f tokens $tokens[..$index] \'\' $tokens[$(math $index + 1)..]
74+
set -l index (count (_swift_math_tokens -pc))
75+
set tokens $tokens[..$index] \'\' $tokens[$(math $index + 1)..]
7676
end
7777
command $tokens[1] $argv $tokens
7878
end

Tests/ArgumentParserUnitTests/Snapshots/testBase_Fish().fish

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function _swift_base-test_should_offer_completions_for -a expected_commands -a expected_positional_index
2-
set -f unparsed_tokens (_swift_base-test_tokens -pc)
3-
set -f positional_index 0
4-
set -f commands
2+
set -l unparsed_tokens (_swift_base-test_tokens -pc)
3+
set -l positional_index 0
4+
set -l commands
55

66
switch $unparsed_tokens[1]
77
case 'base-test'
@@ -29,8 +29,8 @@ end
2929

3030
function _swift_base-test_parse_subcommand -S
3131
argparse -s r -- $argv
32-
set -f positional_count $argv[1]
33-
set -f option_specs $argv[2..]
32+
set -l positional_count $argv[1]
33+
set -l option_specs $argv[2..]
3434

3535
set -a commands $unparsed_tokens[1]
3636
set -e unparsed_tokens[1]
@@ -49,20 +49,20 @@ function _swift_base-test_parse_subcommand -S
4949
end
5050

5151
function _swift_base-test_complete_directories
52-
set -f token (commandline -t)
52+
set -l token (commandline -t)
5353
string match -- '*/' $token
54-
set -f subdirs $token*/
54+
set -l subdirs $token*/
5555
printf '%s\n' $subdirs
5656
end
5757

5858
function _swift_base-test_custom_completion
5959
set -x SAP_SHELL fish
6060
set -x SAP_SHELL_VERSION $FISH_VERSION
6161

62-
set -f tokens (_swift_base-test_tokens -p)
62+
set -l tokens (_swift_base-test_tokens -p)
6363
if test -z "$(_swift_base-test_tokens -t)"
64-
set -f index (count (_swift_base-test_tokens -pc))
65-
set -f tokens $tokens[..$index] \'\' $tokens[$(math $index + 1)..]
64+
set -l index (count (_swift_base-test_tokens -pc))
65+
set tokens $tokens[..$index] \'\' $tokens[$(math $index + 1)..]
6666
end
6767
command $tokens[1] $argv $tokens
6868
end

0 commit comments

Comments
 (0)