Documentation ¶
Overview ¶
Package flagutil is a helper package for processing and interactive command line flags
Index ¶
- Constants
- Variables
- func DebugEnabled() bool
- func EnableOutputFlagCompletion(cmd *cobra.Command)
- func EnableStaticFlagCompletion(cmd *cobra.Command, flagName string, validValues []string)
- func FlagDescription(localizer localize.Localizer, messageID string, validOptions ...string) string
- func IsTriboolValid(val string) error
- func IsValidInput(input string, validValues ...string) bool
- func RegisterServiceAccountCompletionFunc(cmd *cobra.Command, f *factory.Factory) error
- func RegisterUserCompletionFunc(cmd *cobra.Command, flagName string, f *factory.Factory) error
- func RequiredWhenNonInteractiveError(flags ...string) error
- func StringInSlice(a string, list []string) bool
- func ValidateOutput(v string) error
- func VerboseFlag(flags *pflag.FlagSet)
- type Error
- type FlagOptions
- type FlagSet
- type Tribool
Constants ¶
const ( TRIBOOL_TRUE = "true" TRIBOOL_FALSE = "false" TRIBOOL_DEFAULT = "" )
Variables ¶
var (
ValidOutputFormats = []string{dump.JSONFormat, dump.YAMLFormat, dump.YMLFormat}
)
var ValidTribools = []string{ TRIBOOL_TRUE, TRIBOOL_FALSE, TRIBOOL_DEFAULT, }
ValidTribools is an array of valid tribool string values
Functions ¶
func DebugEnabled ¶
func DebugEnabled() bool
DebugEnabled returns a boolean flag that indicates if the verbose mode is enabled
func EnableOutputFlagCompletion ¶
EnableOutputFlagCompletion enables autocompletion for output flag
func EnableStaticFlagCompletion ¶
EnableStaticFlagCompletion enables autocompletion for flags with predefined valid values
func FlagDescription ¶
FlagDescription creates a flag description and adds a list of valid options (if any)
func IsTriboolValid ¶
IsTriboolValid validates if a string corresponds to a valid tribool value
func IsValidInput ¶
IsValidInput checks if the input value is in the range of valid values
func RegisterServiceAccountCompletionFunc ¶
RegisterServiceAccountCompletionFunc adds the service account list to flag dynamic completion
func RegisterUserCompletionFunc ¶
RegisterUserCompletionFunc adds the user list to flag dynamic completion
func StringInSlice ¶ added in v0.41.2
StringInSlice checks if a string is in a slice. It is used when array of strings is passed as flag value or argument
func ValidateOutput ¶
ValidateOutput checks if value v is a valid value for --output
func VerboseFlag ¶
VerboseFlag adds the verbose flag to the given set of command line flags.
Types ¶
type Error ¶
type Error struct {
Err error
}
func InvalidValueError ¶
InvalidValueError returns an error when an invalid flag value is provided
type FlagOptions ¶
type FlagOptions struct {
Required func() error
}
FlagOptions defines additional flag options
func WithFlagOptions ¶
func WithFlagOptions(cmd *cobra.Command, flagName string) *FlagOptions
WithFlagOptions returns additional functions to custom the default flag settings
type FlagSet ¶
func NewFlagSet ¶
NewFlagSet returns a new flag set with some common flags
func (*FlagSet) AddBypassTermsCheck ¶
AddBypassTermsCheck adds a flag to allow bypassing of the terms check before creating an instance