chore: go mod tidy / vendor / make deps
This commit is contained in:
19
vendor/github.com/spf13/cobra/completions.go
generated
vendored
19
vendor/github.com/spf13/cobra/completions.go
generated
vendored
@ -115,6 +115,13 @@ type CompletionOptions struct {
|
||||
DisableDescriptions bool
|
||||
// HiddenDefaultCmd makes the default 'completion' command hidden
|
||||
HiddenDefaultCmd bool
|
||||
// DefaultShellCompDirective sets the ShellCompDirective that is returned
|
||||
// if no special directive can be determined
|
||||
DefaultShellCompDirective *ShellCompDirective
|
||||
}
|
||||
|
||||
func (receiver *CompletionOptions) SetDefaultShellCompDirective(directive ShellCompDirective) {
|
||||
receiver.DefaultShellCompDirective = &directive
|
||||
}
|
||||
|
||||
// Completion is a string that can be used for completions
|
||||
@ -375,7 +382,7 @@ func (c *Command) getCompletions(args []string) (*Command, []Completion, ShellCo
|
||||
// Error while attempting to parse flags
|
||||
if flagErr != nil {
|
||||
// If error type is flagCompError and we don't want flagCompletion we should ignore the error
|
||||
if _, ok := flagErr.(*flagCompError); !(ok && !flagCompletion) {
|
||||
if _, ok := flagErr.(*flagCompError); !ok || flagCompletion {
|
||||
return finalCmd, []Completion{}, ShellCompDirectiveDefault, flagErr
|
||||
}
|
||||
}
|
||||
@ -480,6 +487,14 @@ func (c *Command) getCompletions(args []string) (*Command, []Completion, ShellCo
|
||||
}
|
||||
} else {
|
||||
directive = ShellCompDirectiveDefault
|
||||
// check current and parent commands for a custom DefaultShellCompDirective
|
||||
for cmd := finalCmd; cmd != nil; cmd = cmd.parent {
|
||||
if cmd.CompletionOptions.DefaultShellCompDirective != nil {
|
||||
directive = *cmd.CompletionOptions.DefaultShellCompDirective
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if flag == nil {
|
||||
foundLocalNonPersistentFlag := false
|
||||
// If TraverseChildren is true on the root command we don't check for
|
||||
@ -773,7 +788,7 @@ See each sub-command's help for details on how to use the generated script.
|
||||
// shell completion for it (prog __complete completion '')
|
||||
subCmd, cmdArgs, err := c.Find(args)
|
||||
if err != nil || subCmd.Name() != compCmdName &&
|
||||
!(subCmd.Name() == ShellCompRequestCmd && len(cmdArgs) > 1 && cmdArgs[0] == compCmdName) {
|
||||
(subCmd.Name() != ShellCompRequestCmd || len(cmdArgs) <= 1 || cmdArgs[0] != compCmdName) {
|
||||
// The completion command is not being called or being completed so we remove it.
|
||||
c.RemoveCommand(completionCmd)
|
||||
return
|
||||
|
Reference in New Issue
Block a user