-
Notifications
You must be signed in to change notification settings - Fork 352
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Dashes aren't valid variable identifier characters for Zsh (and maybe Bash just Zsh). When building a completion script for a command that includes one or more dashes in the command name, the completion script prints errors instead of providing completions.
ArgumentParser version: main branch
Swift version: Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Checklist
- If possible, I've reproduced the issue using the
mainbranch of this package - I've searched for existing GitHub issues
Steps to Reproduce
Create a CLI tool with a dash in the command name, then generate and install a Zsh completion script for the command.
Command:
struct ExampleCommand: ParsableCommand {
@Option var name: String
@Flag var verbose = false
}Script:
#compdef example-command
local context state state_descr line
_example-command_commandname=$words[1]
typeset -A opt_args
_example-command() {
integer ret=1
local -a args
args+=(
'--name:name:'
'--verbose'
'(-h --help)'{-h,--help}'[Print help information.]'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_custom_completion() {
local completions=("${(@f)$($*)}")
_describe '' completions
}
_example-command
Expected behavior
Typing example-command and then TAB should offer completions.
Actual behavior
The shell prints _example-command:3: command not found: _example-command_commandname=example-command.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers