Documentation
¶
Overview ¶
Package cli holds what the command packages share.
Index ¶
- func CompleteFirstVaultName(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
- func CompleteVaultNames(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)
- func NeedsCommand(c *cobra.Command, args []string) error
- func NoArgs(c *cobra.Command, args []string) error
- func Plural(n int, word string) string
- func RequireArgs(minArgs, maxArgs int, want string) cobra.PositionalArgs
- func Usage(err error) error
- func Usagef(format string, a ...any) error
- type UsageError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompleteFirstVaultName ¶ added in v0.2.0
func CompleteFirstVaultName(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
CompleteFirstVaultName offers vault names for the first operand only, for a command whose later operands name no vault, as rename's target is a name that no vault has yet.
func CompleteVaultNames ¶ added in v0.2.0
func CompleteVaultNames(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)
CompleteVaultNames offers the names of the vaults that exist, for an operand or a flag that names one. A shell asks for completions on every Tab, so a failure offers nothing rather than putting an error on the command line. Filenames are never offered alongside: a vault is named, not pathed.
func NeedsCommand ¶
NeedsCommand refuses a command group invoked with no command, and an argument that names none. Both are wrong invocations: naming a command is how anything happens, and --help is how help is asked for. It validates arguments rather than running, so that the failure comes before usage is silenced and the reader is shown the commands they could have named.
func NoArgs ¶
NoArgs refuses operands. cobra.NoArgs reports them as an unknown command, which misdescribes a command that takes no operands at all rather than one that was misspelled.
func RequireArgs ¶
func RequireArgs(minArgs, maxArgs int, want string) cobra.PositionalArgs
RequireArgs validates an operand count, naming the command and what it wanted. Cobra's own message ("accepts between 1 and 2 arg(s), received 0") names neither. A maxArgs below zero means there is no upper bound.
Types ¶
type UsageError ¶
type UsageError struct {
// contains filtered or unexported fields
}
UsageError marks a wrong invocation: an unknown command, an unknown flag, or an argument a command does not take. mrs exits 2 for these and 1 for a command that ran and failed, so that a script can tell them apart.
func (UsageError) Error ¶
func (e UsageError) Error() string
func (UsageError) Unwrap ¶
func (e UsageError) Unwrap() error