diff --git a/Sources/ArgumentParser/Completions/CompletionsGenerator.swift b/Sources/ArgumentParser/Completions/CompletionsGenerator.swift index f10749074..213717b5e 100644 --- a/Sources/ArgumentParser/Completions/CompletionsGenerator.swift +++ b/Sources/ArgumentParser/Completions/CompletionsGenerator.swift @@ -149,12 +149,13 @@ extension ArgumentDefinition { /// Returns a string with the arguments for the callback to generate custom completions for /// this argument. func customCompletionCall(_ commands: [ParsableCommand.Type]) -> String { - let subcommandNames = commands.dropFirst().map { $0._commandName }.joined( - separator: " ") + let subcommandNames = + commands.dropFirst().map { "\($0._commandName) " }.joined() let argumentName = names.preferredName?.synopsisString - ?? self.help.keys.first?.fullPathString ?? "---" - return "---completion \(subcommandNames) -- \(argumentName)" + ?? self.help.keys.first?.fullPathString + ?? "---" + return "---completion \(subcommandNames)-- \(argumentName)" } } diff --git a/Tests/ArgumentParserUnitTests/Snapshots/testBase_Bash().bash b/Tests/ArgumentParserUnitTests/Snapshots/testBase_Bash().bash index 8da5e1893..6fc57bb40 100644 --- a/Tests/ArgumentParserUnitTests/Snapshots/testBase_Bash().bash +++ b/Tests/ArgumentParserUnitTests/Snapshots/testBase_Bash().bash @@ -182,11 +182,11 @@ _base_test() { # Offer positional completions case "${positional_number}" in 1) - __base_test_add_completions -W "$(__base_test_custom_complete ---completion -- argument)" + __base_test_add_completions -W "$(__base_test_custom_complete ---completion -- argument)" return ;; 2) - __base_test_add_completions -W "$(__base_test_custom_complete ---completion -- nested.nestedArgument)" + __base_test_add_completions -W "$(__base_test_custom_complete ---completion -- nested.nestedArgument)" return ;; esac diff --git a/Tests/ArgumentParserUnitTests/Snapshots/testBase_Fish().fish b/Tests/ArgumentParserUnitTests/Snapshots/testBase_Fish().fish index 03a03de7b..ac32cce50 100644 --- a/Tests/ArgumentParserUnitTests/Snapshots/testBase_Fish().fish +++ b/Tests/ArgumentParserUnitTests/Snapshots/testBase_Fish().fish @@ -80,8 +80,8 @@ complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test"' -l kind-counter complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test"' -l rep1 -rfka '' complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test"' -s r -l rep2 -rfka '' -complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 1' -fka '(__base-test_custom_completion ---completion -- argument)' -complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 2' -fka '(__base-test_custom_completion ---completion -- nested.nestedArgument)' +complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 1' -fka '(__base-test_custom_completion ---completion -- argument)' +complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 2' -fka '(__base-test_custom_completion ---completion -- nested.nestedArgument)' complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test"' -s h -l help -d 'Show help information.' complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 3' -fa 'sub-command' -d '' complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test" 3' -fa 'escaped-command' -d '' diff --git a/Tests/ArgumentParserUnitTests/Snapshots/testBase_Zsh().zsh b/Tests/ArgumentParserUnitTests/Snapshots/testBase_Zsh().zsh index 0b0762c78..6a046fb81 100644 --- a/Tests/ArgumentParserUnitTests/Snapshots/testBase_Zsh().zsh +++ b/Tests/ArgumentParserUnitTests/Snapshots/testBase_Zsh().zsh @@ -47,8 +47,8 @@ _base-test() { '*--kind-counter' '*--rep1:rep1:' '*'{-r,--rep2}':rep2:' - ':argument:{__base-test_custom_complete "${command_name}" ---completion -- argument "${command_line[@]}"}' - ':nested-argument:{__base-test_custom_complete "${command_name}" ---completion -- nested.nestedArgument "${command_line[@]}"}' + ':argument:{__base-test_custom_complete "${command_name}" ---completion -- argument "${command_line[@]}"}' + ':nested-argument:{__base-test_custom_complete "${command_name}" ---completion -- nested.nestedArgument "${command_line[@]}"}' '(-h --help)'{-h,--help}'[Show help information.]' '(-): :->command' '(-)*:: :->arg'