mirror of
https://github.com/spf13/cobra
synced 2025-05-06 05:17:21 +00:00
add additional support for argument aliases.
This commit is contained in:
parent
575081ea12
commit
5697159013
2 changed files with 11 additions and 1 deletions
|
@ -50,7 +50,7 @@ func writeFishCommandCompletion(rootCmd, cmd *Command, buf *bytes.Buffer) {
|
|||
condition := commandCompletionCondition(rootCmd, cmd)
|
||||
buf.WriteString(fmt.Sprintf("complete -c %s -f %s -a %s -d '%s'\n", rootCmd.Name(), condition, subCmd.Name(), subCmd.Short))
|
||||
})
|
||||
for _, validArg := range cmd.ValidArgs {
|
||||
for _, validArg := range append(cmd.ValidArgs, cmd.ArgAliases...) {
|
||||
condition := commandCompletionCondition(rootCmd, cmd)
|
||||
buf.WriteString(
|
||||
fmt.Sprintf("complete -c %s -f %s -a %s -d '%s'\n",
|
||||
|
|
|
@ -117,4 +117,14 @@ func TestFishCompletions(t *testing.T) {
|
|||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a node`)
|
||||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a service`)
|
||||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a replicationcontroller`)
|
||||
|
||||
// check for aliases to positional arguments for a command
|
||||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a pods`)
|
||||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a nodes`)
|
||||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a services`)
|
||||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a replicationcontrollers`)
|
||||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a po`)
|
||||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a no`)
|
||||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a svc`)
|
||||
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a rc`)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue