summaryrefslogtreecommitdiff
path: root/vendor/github.com/spf13/cobra/command.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/cobra/command.go')
-rw-r--r--vendor/github.com/spf13/cobra/command.go33
1 files changed, 8 insertions, 25 deletions
diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go
index 9f33a461f..d6732ad11 100644
--- a/vendor/github.com/spf13/cobra/command.go
+++ b/vendor/github.com/spf13/cobra/command.go
@@ -63,9 +63,9 @@ type Command struct {
// Example is examples of how to use the command.
Example string
- // ValidArgs is list of all valid non-flag arguments that are accepted in shell completions
+ // ValidArgs is list of all valid non-flag arguments that are accepted in bash completions
ValidArgs []string
- // ValidArgsFunction is an optional function that provides valid non-flag arguments for shell completion.
+ // ValidArgsFunction is an optional function that provides valid non-flag arguments for bash completion.
// It is a dynamic version of using ValidArgs.
// Only one of ValidArgs and ValidArgsFunction can be used for a command.
ValidArgsFunction func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)
@@ -74,12 +74,11 @@ type Command struct {
Args PositionalArgs
// ArgAliases is List of aliases for ValidArgs.
- // These are not suggested to the user in the shell completion,
+ // These are not suggested to the user in the bash completion,
// but accepted if entered manually.
ArgAliases []string
- // BashCompletionFunction is custom bash functions used by the legacy bash autocompletion generator.
- // For portability with other shells, it is recommended to instead use ValidArgsFunction
+ // BashCompletionFunction is custom functions used by the bash autocompletion generator.
BashCompletionFunction string
// Deprecated defines, if this command is deprecated and should print this string when used.
@@ -142,9 +141,6 @@ type Command struct {
// that we can use on every pflag set and children commands
globNormFunc func(f *flag.FlagSet, name string) flag.NormalizedName
- //flagCompletionFunctions is map of flag completion functions.
- flagCompletionFunctions map[*flag.Flag]func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)
-
// usageFunc is usage func defined by user.
usageFunc func(*Command) error
// usageTemplate is usage template defined by user.
@@ -172,9 +168,6 @@ type Command struct {
//FParseErrWhitelist flag parse errors to be ignored
FParseErrWhitelist FParseErrWhitelist
- // CompletionOptions is a set of options to control the handling of shell completion
- CompletionOptions CompletionOptions
-
// commandsAreSorted defines, if command slice are sorted or not.
commandsAreSorted bool
// commandCalledAs is the name or alias value used to call this command.
@@ -891,8 +884,7 @@ func (c *Command) preRun() {
}
// ExecuteContext is the same as Execute(), but sets the ctx on the command.
-// Retrieve ctx by calling cmd.Context() inside your *Run lifecycle or ValidArgs
-// functions.
+// Retrieve ctx by calling cmd.Context() inside your *Run lifecycle functions.
func (c *Command) ExecuteContext(ctx context.Context) error {
c.ctx = ctx
return c.Execute()
@@ -906,14 +898,6 @@ func (c *Command) Execute() error {
return err
}
-// ExecuteContextC is the same as ExecuteC(), but sets the ctx on the command.
-// Retrieve ctx by calling cmd.Context() inside your *Run lifecycle or ValidArgs
-// functions.
-func (c *Command) ExecuteContextC(ctx context.Context) (*Command, error) {
- c.ctx = ctx
- return c.ExecuteC()
-}
-
// ExecuteC executes the command.
func (c *Command) ExecuteC() (cmd *Command, err error) {
if c.ctx == nil {
@@ -930,10 +914,9 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
preExecHookFn(c)
}
- // initialize help at the last point to allow for user overriding
+ // initialize help as the last point possible to allow for user
+ // overriding
c.InitDefaultHelpCmd()
- // initialize completion at the last point to allow for user overriding
- c.initDefaultCompletionCmd()
args := c.args
@@ -942,7 +925,7 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
args = os.Args[1:]
}
- // initialize the hidden command to be used for shell completion
+ // initialize the hidden command to be used for bash completion
c.initCompleteCmd(args)
var flags []string