Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NamespaceNameOnlyUseLine string NamespaceNameOnlyValidator cobra.PositionalArgs VClusterNameOnlyUseLine string VClusterNameOnlyValidator cobra.PositionalArgs )
View Source
var ( ErrNonInteractive = errors.New("terminal is not interactive") ErrTooManyArguments = errors.New("too many arguments specified") )
Functions ¶
func NamedPositionalArgsValidator ¶
func NamedPositionalArgsValidator(failMissing, failExtra bool, expectedArgs ...string) (string, cobra.PositionalArgs)
NamedPositionalArgsValidator returns a cobra.PositionalArgs that returns a helpful error message if the arg number doesn't match. It also returns a string that can be appended to the cobra useline
Example output for extra arguments with :
$ command arg asdf [fatal] command ARG_1 [flags] Invalid Args: received 2 arguments, expected 1, extra arguments: "asdf" Run with --help for more details
Example output for missing arguments:
$ command [fatal] command ARG_1 [flags] Invalid Args: received 0 arguments, expected 1, please specify missing: "ARG_!" Run with --help for more details on arguments
func PromptForArgs ¶ added in v0.21.0
PromptForArgs expects that the terminal is interactive and the number of args, matched the number of argNames, in the order they should appear and will prompt one by one for the missing args adding them to the args slice and returning a new set for a command to use. It returns the args, rather than a nil slice so they're unaltered in error cases.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.