Documentation ¶
Overview ¶
Package flagutil is a helper package for processing and interactive command line flags
Index ¶
- Constants
- Variables
- 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 RegisterGroupCompletionFunc(cmd *cobra.Command, f *factory.Factory) error
- func RegisterServiceAccountCompletionFunc(cmd *cobra.Command, f *factory.Factory) error
- func RegisterTopicCompletionFunc(cmd *cobra.Command, f *factory.Factory) error
- func RegisterUserCompletionFunc(cmd *cobra.Command, flagName string, f *factory.Factory) 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} CredentialsOutputFormats = []string{credentials.EnvFormat, credentials.JSONFormat, credentials.PropertiesFormat} )
var ValidTribools = []string{ TRIBOOL_TRUE, TRIBOOL_FALSE, TRIBOOL_DEFAULT, }
ValidTribools is an array of valid tribool string values
Functions ¶
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 ¶ added in v0.37.0
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 RegisterGroupCompletionFunc ¶ added in v0.36.3
RegisterGroupCompletionFunc enables dynamic autocompletion for group flag
func RegisterServiceAccountCompletionFunc ¶
RegisterServiceAccountCompletionFunc adds the service account list to flag dynamic completion
func RegisterTopicCompletionFunc ¶ added in v0.36.3
RegisterTopicCompletionFunc enables dynamic autocompletion for topic flag
Types ¶
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 ¶ added in v0.36.2
AddBypassTermsCheck adds a flag to allow bypassing of the terms check before creating an instance
func (*FlagSet) TriBoolVar ¶ added in v0.37.0
TriBoolVar defines a tribool flag with specified name, default value, and usage string. The argument p points to a tribool variable in which to store the value of the flag.
type Tribool ¶ added in v0.37.0
type Tribool string
Tribool is a tri-state boolean where extra state corresponds to ""
func (*Tribool) Set ¶ added in v0.37.0
Set accepts the CLI input as string and assigns it to the tribool variable