flags

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CIDRFlag

func CIDRFlag() *cidrFlag

CIDRFlag returns a flag which must be a valid CIDR.

func CIDRSliceFlag

func CIDRSliceFlag() *cidrSliceFlag

CIDRSliceFlag returns a flag which must be a valid CIDR slice.

func EnumFlag

func EnumFlag(ignoreCase bool, defaultValue string, options ...string) *enumFlag

EnumFlag returns a flag which must be one of the given values. If ignoreCase is true, flag value is returned in lower case.

func EnumSliceFlag

func EnumSliceFlag(ignoreCase bool, defaultValues []string, options ...string) *enumSliceFlag

EnumSliceFlag returns a flag which is a slice which values must be one of the given values. If ignoreCase is true, values are returned in lower case.

func FlagToBoolPointer

func FlagToBoolPointer(p *print.Printer, cmd *cobra.Command, flag string) *bool

Returns a pointer to the flag's value. Returns nil if the flag is not set, if its value can not be converted to bool, or if the flag does not exist.

func FlagToBoolValue

func FlagToBoolValue(p *print.Printer, cmd *cobra.Command, flag string) bool

Returns the flag's value as a bool. Returns false if its value can not be converted to bool, or if the flag does not exist.

func FlagToDateTimePointer

func FlagToDateTimePointer(p *print.Printer, cmd *cobra.Command, flag, format string) (*time.Time, error)

Returns a pointer to the flag's value. Returns nil if the flag is not set, or if the flag does not exist. Returns an error if its value can not be converted to a date time with the provided format.

func FlagToInt64Pointer

func FlagToInt64Pointer(p *print.Printer, cmd *cobra.Command, flag string) *int64

Returns a pointer to the flag's value. Returns nil if the flag is not set, if its value can not be converted to int64, or if the flag does not exist.

func FlagToStringPointer

func FlagToStringPointer(p *print.Printer, cmd *cobra.Command, flag string) *string

Returns a pointer to the flag's value. Returns nil if the flag is not set, if its value can not be converted to string, or if the flag does not exist.

func FlagToStringSlicePointer

func FlagToStringSlicePointer(p *print.Printer, cmd *cobra.Command, flag string) *[]string

Returns a pointer to the flag's value. Returns nil if the flag is not set, if its value can not be converted to []string, or if the flag does not exist.

func FlagToStringSliceValue

func FlagToStringSliceValue(p *print.Printer, cmd *cobra.Command, flag string) []string

Returns the flag's value as a []string. Returns nil if the flag is not set, if its value can not be converted to []string, or if the flag does not exist.

func FlagToStringToStringPointer

func FlagToStringToStringPointer(p *print.Printer, cmd *cobra.Command, flag string) *map[string]string

Returns a pointer to the flag's value. Returns nil if the flag is not set, if its value can not be converted to map[string]string, or if the flag does not exist.

func FlagToStringValue

func FlagToStringValue(p *print.Printer, cmd *cobra.Command, flag string) string

Returns the flag's value as a string. Returns "" if the flag is not set, if its value can not be converted to string, or if the flag does not exist.

func FlagWithDefaultToInt64Value

func FlagWithDefaultToInt64Value(p *print.Printer, cmd *cobra.Command, flag string) int64

Returns the int64 value set on the flag. If no value is set, returns the flag's default value. Returns 0 if the flag value can not be converted to int64 or if the flag does not exist.

func FlagWithDefaultToStringSlicePointer

func FlagWithDefaultToStringSlicePointer(p *print.Printer, cmd *cobra.Command, flag string) *[]string

Returns a pointer to the flag's value. If no value is set, returns the flag's default value. Returns nil if the flag value can't be converted to []string or if the flag does not exist.

func FlagWithDefaultToStringValue

func FlagWithDefaultToStringValue(p *print.Printer, cmd *cobra.Command, flag string) string

Returns the string value set on the flag. If no value is set, returns the flag's default value. Returns nil if the flag value can not be converted to string or if the flag does not exist.

func MarkFlagsRequired

func MarkFlagsRequired(cmd *cobra.Command, flags ...string) error

Marks all given flags as required, causing the command to report an error if invoked without them.

func ReadFromFileFlag

func ReadFromFileFlag() *readFromFileFlag

ReadFromFileFlag returns a string flag. If it starts with "@", it is assumed to be a file path and content is read from file instead

func UUIDFlag

func UUIDFlag() *uuidFlag

UUIDFlag returns a flag which must be a valid UUID.

func UUIDSliceFlag

func UUIDSliceFlag() *uuidSliceFlag

UUIDSliceFlag returns a flag which must be a valid slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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