Documentation
¶
Index ¶
- func NewBoolFlag(flags *pflag.FlagSet, name string, short string, defaultValue bool, ...) *boolFlag
- func NewDurationFlag(flags *pflag.FlagSet, required bool, name string, short string, ...) *durationFlag
- func NewIntegerFlag(flags *pflag.FlagSet, required bool, name string, short string, ...) *integerFlag
- func NewStringFlag(flags *pflag.FlagSet, required bool, name, short, defaultValue, desc string) *stringFlag
- func NewStringSliceFlag(flags *pflag.FlagSet, required bool, name, short string, defaultValue []string, ...) *stringSliceFlag
- func NewTimestampFlag(flags *pflag.FlagSet, required bool, name string, short string, ...) *timestampFlag
- func NewUUIDFlag(flags *pflag.FlagSet, required bool, name string, short string, ...) *uuidFlag
- type BoolFlag
- type ConflictingFlagsError
- type DurationFlag
- type FileFlag
- type HumanDurationFlag
- type IntegerFlag
- type IntegerFlagInvalidValueError
- type InvalidDurationFlagError
- type InvalidFileFlagError
- type InvalidTimestampFlagError
- type InvalidUUIDFlagError
- type OrgIDFlag
- type RequiredFlagNotSetError
- type StringFlag
- type StringSliceFlag
- type TimestampFlag
- type UUIDFlag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBoolFlag ¶
func NewBoolFlag(flags *pflag.FlagSet, name string, short string, defaultValue bool, desc string) *boolFlag
NewBoolFlag instantiates a new boolean flag on a given flag set. Returns a BoolFlag that can be used to get the value of the flag. name: long flag name short: shorthand letter (or empty) defaultValue: default boolean value desc: user-facing description shown in help
func NewDurationFlag ¶
func NewDurationFlag(flags *pflag.FlagSet, required bool, name string, short string, defaultValue mo.Option[time.Duration], desc string) *durationFlag
NewDurationFlag instantiates a new duration flag on a given flag set. Returns a DurationFlag that can be used to get the value of the flag. Note that flags can be required or have default values, but it doesn't make sense to have both. Misuse will panic to surface programmer error early.
func NewIntegerFlag ¶
func NewIntegerFlag( flags *pflag.FlagSet, required bool, name string, short string, defaultValue mo.Option[int64], desc string, minValue mo.Option[int64], maxValue mo.Option[int64], ) *integerFlag
NewIntegerFlag instantiates a new integer flag on a given flag set. Returns an IntegerFlag that can be used to get the value of the flag. required: whether the flag is required name: long flag name short: shorthand letter (or empty) defaultValue: default integer value (ignored if required) desc: user-facing description shown in help minValue: minimum allowed value (optional) maxValue: maximum allowed value (optional)
func NewStringFlag ¶
func NewStringFlag(flags *pflag.FlagSet, required bool, name, short, defaultValue, desc string) *stringFlag
NewStringFlag instantiates a new string flag on a given flag set. Returns a StringFlag that can be used to get the value of the flag. Note that flags can be required or have default values, but it doesn't make sense to have both. Misuse will panic to surface programmer error early. name: long flag name (e.g., "organization-id") short: shorthand letter (or empty) defaultValue: default string value (ignored if required) desc: user-facing description shown in help
func NewStringSliceFlag ¶
func NewStringSliceFlag(flags *pflag.FlagSet, required bool, name, short string, defaultValue []string, desc string) *stringSliceFlag
NewStringSliceFlag instantiates a new string slice flag on a given flag set. Returns a StringSliceFlag that can be used to get the slice of values. The flag can be specified multiple times and values will be accumulated. name: long flag name (e.g., "tags") short: shorthand letter (or empty) defaultValue: default slice of strings (ignored if required) desc: user-facing description shown in help
func NewTimestampFlag ¶
func NewTimestampFlag(flags *pflag.FlagSet, required bool, name string, short string, defaultValue mo.Option[time.Time], desc string) *timestampFlag
NewTimestampFlag instantiates a new timestamp flag on a given flag set. Returns a TimestampFlag that can be used to get the value of the flag. Note that flags can be required or have default values, but it doesn't make sense to have both. Misuse will panic to surface programmer error early.
func NewUUIDFlag ¶
func NewUUIDFlag(flags *pflag.FlagSet, required bool, name string, short string, defaultValue mo.Option[uuid.UUID], desc string) *uuidFlag
NewUUIDFlag instantiates a new UUID flag on a given flag set. Returns a UUIDFlag that can be used to get the value of the flag. Note that flags can be required or have default values, but it doesn't make sense to have both. Misuse will panic to surface programmer error early. When calling Value, an error of type InvalidUUIDFlagError will be returned if the UUID is invalid.
Types ¶
type BoolFlag ¶
type BoolFlag interface {
// Value returns the current value of the flag.
// If the flag is not provided, it will return the default value.
Value() (bool, cenclierrors.CencliError)
}
BoolFlag represents a boolean-based command-line flag.
type ConflictingFlagsError ¶
type ConflictingFlagsError interface {
cenclierrors.CencliError
}
func NewConflictingFlagsError ¶
func NewConflictingFlagsError(flag1 string, flag2 string) ConflictingFlagsError
type DurationFlag ¶
type DurationFlag interface {
// Value returns the current value of the flag.
// If the flag is marked as required but not provided,
// it returns an error of type RequiredFlagNotSetError.
// If the flag has an invalid duration, it returns an error of type InvalidDurationFlagError.
// An optional value is returned to keep callers from having to compare to 0.
Value() (mo.Option[time.Duration], cenclierrors.CencliError)
}
DurationFlag represents a duration-based command-line flag.
type FileFlag ¶
type FileFlag interface {
// Value returns the value of the flag.
// Errors if the file does not exist or is not readable.
// Special case: a value of "-" is treated as STDIN and returned as-is without filesystem validation.
Value() (string, cenclierrors.CencliError)
// IsSet returns true if the flag is set.
IsSet() bool
// Lines returns the lines of the file.
// Takes in a cobra command in case it needs to access its stdin reader.
// The command is not used if the flag value is a real file.
Lines(*cobra.Command) ([]string, cenclierrors.CencliError)
}
FileFlag represents a file-based command-line flag. Provides validation on retrieval via Lines().
func NewFileFlag ¶
func NewFileFlag(flags *pflag.FlagSet, required bool, name string, short string, desc string) FileFlag
NewFileFlag instantiates a new file flag on a given flag set. Returns a FileFlag that can be used to get the value of the flag. When calling Value, an error of type InvalidFileFlagError will be returned if the file does not exist or is not readable. Special case: a value of "-" is treated as STDIN and returned as-is without filesystem validation.
type HumanDurationFlag ¶
type HumanDurationFlag interface {
// Value returns the current value of the flag.
// If the flag is marked as required but not provided,
// it returns an error of type RequiredFlagNotSetError.
// If the flag has an invalid duration, it returns an error of type InvalidDurationFlagError.
// An optional value is returned to keep callers from having to compare to 0.
Value() (mo.Option[time.Duration], cenclierrors.CencliError)
}
HumanDurationFlag represents a duration flag that accepts extended units like d, w, y. Examples: "2h", "30m", "7d", "1w", "1y", or combinations like "1d12h". Returns a time.Duration after normalizing to hours.
func NewHumanDurationFlag ¶
func NewHumanDurationFlag(flags *pflag.FlagSet, required bool, name, short string, defaultValue mo.Option[time.Duration], desc string) HumanDurationFlag
NewHumanDurationFlag instantiates a new extended duration flag on a given flag set. Supports Go durations (e.g., 2h45m) and human units d=24h, w=7d, y=365d.
type IntegerFlag ¶
type IntegerFlag interface {
// Value returns the current value of the flag.
// If the flag is not provided, it will return the default value.
// An optional value is returned to distinguish between 0 and not provided.
Value() (mo.Option[int64], cenclierrors.CencliError)
}
type IntegerFlagInvalidValueError ¶
type IntegerFlagInvalidValueError interface {
cenclierrors.CencliError
}
func NewIntegerFlagInvalidValueError ¶
func NewIntegerFlagInvalidValueError(flagName string, value int64, reason string) IntegerFlagInvalidValueError
type InvalidDurationFlagError ¶
type InvalidDurationFlagError interface {
cenclierrors.CencliError
}
func NewInvalidDurationFlagError ¶
func NewInvalidDurationFlagError(flagName, flagValue string) InvalidDurationFlagError
type InvalidFileFlagError ¶
type InvalidFileFlagError interface {
cenclierrors.CencliError
}
func NewInvalidFileFlagError ¶
func NewInvalidFileFlagError(flagName string, flagValue string, err error) InvalidFileFlagError
type InvalidTimestampFlagError ¶
type InvalidTimestampFlagError interface {
cenclierrors.CencliError
}
func NewInvalidTimestampFlagError ¶
func NewInvalidTimestampFlagError(flagName, flagValue string) InvalidTimestampFlagError
type InvalidUUIDFlagError ¶
type InvalidUUIDFlagError interface {
cenclierrors.CencliError
}
func NewInvalidUUIDFlagError ¶
func NewInvalidUUIDFlagError(flagName string, flagValue string) InvalidUUIDFlagError
type OrgIDFlag ¶
type OrgIDFlag interface {
// Value returns an optional value indicating the current value of the flag.
// If the flag is marked as required but not provided,
// it returns an error of type RequiredFlagNotSetError.
// If the flag has an invalid UUID, it returns an error of type InvalidUUIDFlagError.
// An optional value is returned to keep callers from having to compare to uuid.Nil.
Value() (mo.Option[identifiers.OrganizationID], cenclierrors.CencliError)
}
OrgIDFlag is a domain-specific flag that represents an optional Organization ID.
type RequiredFlagNotSetError ¶
type RequiredFlagNotSetError interface {
cenclierrors.CencliError
}
func NewRequiredFlagNotSetError ¶
func NewRequiredFlagNotSetError(flagName string) RequiredFlagNotSetError
type StringFlag ¶
type StringFlag interface {
// Value returns the current value of the flag.
// If the flag is marked as required but not provided,
// it returns an error of type RequiredFlagNotSetError.
Value() (string, cenclierrors.CencliError)
}
StringFlag represents a string-based command-line flag. Provides validation on retrieval via Value().
type StringSliceFlag ¶
type StringSliceFlag interface {
// Value returns the current slice of values for the flag.
// If the flag is marked as required but not provided,
// it returns an error of type RequiredFlagNotSetError.
Value() ([]string, cenclierrors.CencliError)
}
StringSliceFlag represents a string slice-based command-line flag. Allows multiple values to be provided by specifying the flag multiple times. Provides validation on retrieval via Value().
type TimestampFlag ¶
type TimestampFlag interface {
// Value returns the current value of the flag, using the
// default timezone if no timezone can be inferred.
// If the flag is marked as required but not provided,
// it returns an error of type RequiredFlagNotSetError.
// If the flag has an invalid RFC3339 timestamp, it returns an error of type InvalidRFC3339TimestampFlagError.
// An optional value is returned to keep callers from having to use IsZero().
Value(defaultTZ datetime.TimeZone) (mo.Option[time.Time], cenclierrors.CencliError)
// AddAlias registers an additional flag name and optional shorthand that
// map to the same underlying value. Useful for supporting synonyms like
// "--at" and "-a" for an "--at-time" flag.
AddAlias(name string, short string, desc string) TimestampFlag
}
TimestampFlag represents a timestamp-based command-line flag.
type UUIDFlag ¶
type UUIDFlag interface {
// Value returns an optional value indicating the current value of the flag.
// If the flag is marked as required but not provided,
// it returns an error of type RequiredFlagNotSetError.
// If the flag has an invalid UUID, it returns an error of type InvalidUUIDFlagError.
// An optional value is returned to keep callers from having to compare to uuid.Nil.
Value() (mo.Option[uuid.UUID], cenclierrors.CencliError)
}
UUIDFlag represents a command-line flag that holds a UUID.