Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
Expand Down
4 changes: 2 additions & 2 deletions Tests/ArgumentParserUnitTests/Snapshots/testBase_Zsh().zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down