Documentation
¶
Overview ¶
Package cobraext provides extensions to the cobra package. It provides an UnknownSubcommandAction function that prints an error message for unknown subcommands. This is necessary when using `TraverseChildren: true`, because it seems to disable suggestions for unknown subcommands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSet ¶
IsSet checks if a flag is set in viper, to avoid using it's default values unless explicitly passed.
func PipeOrArg ¶
PipeOrArg reads from either the first argument or stdin. If an argument is provided, it is returned. If no argument is provided but stdin is piped, the stdin content is returned. If neither an argument nor stdin is provided, an empty string is returned.
func UnknownSubcommandAction ¶
UnknownSubcommandAction is a cobra.Command.RunE function that prints an error message for unknown subcommands. Necessary when using `TraverseChildren: true`, because it seems to disable suggestions for unknown subcommands. See: - https://github.com/spf13/cobra/issues/981 - https://github.com/containerd/nerdctl/blob/242e6fc6e861b61b878bd7df8bf25e95674c036d/cmd/nerdctl/main.go#L401-L418
Types ¶
This section is empty.