summaryrefslogtreecommitdiff
path: root/vendor/github.com/spf13/cobra/command.go
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2020-03-30 09:56:41 +0000
committerDaniel J Walsh <dwalsh@redhat.com>2020-03-30 10:00:55 -0400
commit16fa9b6a0baed65ad31ff442255a4d16ccbfcb31 (patch)
treea83d71ef4a9344729213777163a105cc4392b850 /vendor/github.com/spf13/cobra/command.go
parent598bb53d46dfc85b8bcc1e3000736106f80de93e (diff)
downloadpodman-16fa9b6a0baed65ad31ff442255a4d16ccbfcb31.tar.gz
podman-16fa9b6a0baed65ad31ff442255a4d16ccbfcb31.tar.bz2
podman-16fa9b6a0baed65ad31ff442255a4d16ccbfcb31.zip
Bump github.com/spf13/cobra from 0.0.6 to 0.0.7
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 0.0.6 to 0.0.7. - [Release notes](https://github.com/spf13/cobra/releases) - [Commits](https://github.com/spf13/cobra/compare/v0.0.6...0.0.7) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/spf13/cobra/command.go')
-rw-r--r--vendor/github.com/spf13/cobra/command.go24
1 files changed, 9 insertions, 15 deletions
diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go
index fb60ebd93..fdac9d272 100644
--- a/vendor/github.com/spf13/cobra/command.go
+++ b/vendor/github.com/spf13/cobra/command.go
@@ -18,7 +18,6 @@ package cobra
import (
"bytes"
"context"
- "errors"
"fmt"
"io"
"os"
@@ -29,8 +28,6 @@ import (
flag "github.com/spf13/pflag"
)
-var ErrSubCommandRequired = errors.New("subcommand is required")
-
// FParseErrWhitelist configures Flag parse errors to be ignored
type FParseErrWhitelist flag.ParseErrorsWhitelist
@@ -84,7 +81,8 @@ type Command struct {
// Version defines the version for this command. If this value is non-empty and the command does not
// define a "version" flag, a "version" boolean flag will be added to the command and, if specified,
- // will print content of the "Version" variable.
+ // will print content of the "Version" variable. A shorthand "v" flag will also be added if the
+ // command does not define one.
Version string
// The *Run functions are executed in the following order:
@@ -309,7 +307,7 @@ func (c *Command) ErrOrStderr() io.Writer {
return c.getErr(os.Stderr)
}
-// InOrStdin returns output to stderr
+// InOrStdin returns input to stdin
func (c *Command) InOrStdin() io.Reader {
return c.getIn(os.Stdin)
}
@@ -800,7 +798,7 @@ func (c *Command) execute(a []string) (err error) {
}
if !c.Runnable() {
- return ErrSubCommandRequired
+ return flag.ErrHelp
}
c.preRun()
@@ -951,14 +949,6 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
return cmd, nil
}
- // If command wasn't runnable, show full help, but do return the error.
- // This will result in apps by default returning a non-success exit code, but also gives them the option to
- // handle specially.
- if err == ErrSubCommandRequired {
- cmd.HelpFunc()(cmd, args)
- return cmd, err
- }
-
// If root command has SilentErrors flagged,
// all subcommands should respect it
if !cmd.SilenceErrors && !c.SilenceErrors {
@@ -1033,7 +1023,11 @@ func (c *Command) InitDefaultVersionFlag() {
} else {
usage += c.Name()
}
- c.Flags().Bool("version", false, usage)
+ if c.Flags().ShorthandLookup("v") == nil {
+ c.Flags().BoolP("version", "v", false, usage)
+ } else {
+ c.Flags().Bool("version", false, usage)
+ }
}
}