Skip to content

Commit cb5670a

Browse files
authored
Remove extraneous space in shell custom completion calls. (#762)
1 parent bfd1d17 commit cb5670a

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

Sources/ArgumentParser/Completions/CompletionsGenerator.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,13 @@ extension ArgumentDefinition {
149149
/// Returns a string with the arguments for the callback to generate custom completions for
150150
/// this argument.
151151
func customCompletionCall(_ commands: [ParsableCommand.Type]) -> String {
152-
let subcommandNames = commands.dropFirst().map { $0._commandName }.joined(
153-
separator: " ")
152+
let subcommandNames =
153+
commands.dropFirst().map { "\($0._commandName) " }.joined()
154154
let argumentName =
155155
names.preferredName?.synopsisString
156-
?? self.help.keys.first?.fullPathString ?? "---"
157-
return "---completion \(subcommandNames) -- \(argumentName)"
156+
?? self.help.keys.first?.fullPathString
157+
?? "---"
158+
return "---completion \(subcommandNames)-- \(argumentName)"
158159
}
159160
}
160161

Tests/ArgumentParserUnitTests/Snapshots/testBase_Bash().bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ _base_test() {
182182
# Offer positional completions
183183
case "${positional_number}" in
184184
1)
185-
__base_test_add_completions -W "$(__base_test_custom_complete ---completion -- argument)"
185+
__base_test_add_completions -W "$(__base_test_custom_complete ---completion -- argument)"
186186
return
187187
;;
188188
2)
189-
__base_test_add_completions -W "$(__base_test_custom_complete ---completion -- nested.nestedArgument)"
189+
__base_test_add_completions -W "$(__base_test_custom_complete ---completion -- nested.nestedArgument)"
190190
return
191191
;;
192192
esac

Tests/ArgumentParserUnitTests/Snapshots/testBase_Fish().fish

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test"
8080
complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test"' -l kind-counter
8181
complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test"' -l rep1 -rfka ''
8282
complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test"' -s r -l rep2 -rfka ''
83-
complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 1' -fka '(__base-test_custom_completion ---completion -- argument)'
84-
complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 2' -fka '(__base-test_custom_completion ---completion -- nested.nestedArgument)'
83+
complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 1' -fka '(__base-test_custom_completion ---completion -- argument)'
84+
complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 2' -fka '(__base-test_custom_completion ---completion -- nested.nestedArgument)'
8585
complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test"' -s h -l help -d 'Show help information.'
8686
complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 3' -fa 'sub-command' -d ''
8787
complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 3' -fa 'escaped-command' -d ''

Tests/ArgumentParserUnitTests/Snapshots/testBase_Zsh().zsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ _base-test() {
4747
'*--kind-counter'
4848
'*--rep1:rep1:'
4949
'*'{-r,--rep2}':rep2:'
50-
':argument:{__base-test_custom_complete "${command_name}" ---completion -- argument "${command_line[@]}"}'
51-
':nested-argument:{__base-test_custom_complete "${command_name}" ---completion -- nested.nestedArgument "${command_line[@]}"}'
50+
':argument:{__base-test_custom_complete "${command_name}" ---completion -- argument "${command_line[@]}"}'
51+
':nested-argument:{__base-test_custom_complete "${command_name}" ---completion -- nested.nestedArgument "${command_line[@]}"}'
5252
'(-h --help)'{-h,--help}'[Show help information.]'
5353
'(-): :->command'
5454
'(-)*:: :->arg'

0 commit comments

Comments
 (0)