cobraext

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 5 Imported by: 0

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

func IsSet(flag string) bool

IsSet checks if a flag is set in viper, to avoid using it's default values unless explicitly passed.

func PipeOrArg

func PipeOrArg(args []string) (string, error)

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

func UnknownSubcommandAction(cmd *cobra.Command, args []string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL