summaryrefslogtreecommitdiff
path: root/vendor/github.com/spf13/cobra/command.go
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-07-01 19:53:51 +0200
committerPaul Holzinger <pholzing@redhat.com>2021-07-02 17:36:30 +0200
commit924cd37a37f1c58911ce7bc10b82ec9579c5c70e (patch)
tree915c05707555d02ca272036b5bbd55b7d3b41a9a /vendor/github.com/spf13/cobra/command.go
parent04209873562dff25c5d6f800e4a535dff18d485a (diff)
downloadpodman-924cd37a37f1c58911ce7bc10b82ec9579c5c70e.tar.gz
podman-924cd37a37f1c58911ce7bc10b82ec9579c5c70e.tar.bz2
podman-924cd37a37f1c58911ce7bc10b82ec9579c5c70e.zip
Bump github.com/spf13/cobra to v1.2.1
Fixes #9730 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'vendor/github.com/spf13/cobra/command.go')
-rw-r--r--vendor/github.com/spf13/cobra/command.go30
1 files changed, 22 insertions, 8 deletions
diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go
index d6732ad11..2cc18891d 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 bash completions
+ // ValidArgs is list of all valid non-flag arguments that are accepted in shell completions
ValidArgs []string
- // ValidArgsFunction is an optional function that provides valid non-flag arguments for bash completion.
+ // ValidArgsFunction is an optional function that provides valid non-flag arguments for shell 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,11 +74,12 @@ type Command struct {
Args PositionalArgs
// ArgAliases is List of aliases for ValidArgs.
- // These are not suggested to the user in the bash completion,
+ // These are not suggested to the user in the shell completion,
// but accepted if entered manually.
ArgAliases []string
- // BashCompletionFunction is custom functions used by the bash autocompletion generator.
+ // 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 string
// Deprecated defines, if this command is deprecated and should print this string when used.
@@ -168,6 +169,9 @@ 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.
@@ -884,7 +888,8 @@ 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 functions.
+// Retrieve ctx by calling cmd.Context() inside your *Run lifecycle or ValidArgs
+// functions.
func (c *Command) ExecuteContext(ctx context.Context) error {
c.ctx = ctx
return c.Execute()
@@ -898,6 +903,14 @@ 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 {
@@ -914,9 +927,10 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
preExecHookFn(c)
}
- // initialize help as the last point possible to allow for user
- // overriding
+ // initialize help at the last point to allow for user overriding
c.InitDefaultHelpCmd()
+ // initialize completion at the last point to allow for user overriding
+ c.initDefaultCompletionCmd()
args := c.args
@@ -925,7 +939,7 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
args = os.Args[1:]
}
- // initialize the hidden command to be used for bash completion
+ // initialize the hidden command to be used for shell completion
c.initCompleteCmd(args)
var flags []string