Documentation
¶
Index ¶
- func BindFlagsFromStruct(cmd *cobra.Command, opts any) error
- func LoadFromCobraFlags(cmd *cobra.Command, opts any) error
- func LoadFromViper(opts any) error
- func Preflight(zoneRequired bool) func(cmd *cobra.Command, args []string) error
- func SetDefaultZone(zoneID, zoneName string) error
- func TokenFromContext(ctx context.Context) string
- func Validate(cmd *cobra.Command, rules ...Rule) error
- func ZoneIDFromContext(ctx context.Context) string
- type CobraValues
- type FlagSpec
- type Rule
- func ExactlyOne(names ...string) Rule
- func IsUlid(name string) Rule
- func MaxLength(name string, max int) Rule
- func MinLength(name string, min int) Rule
- func MutuallyExclusive(a, b string) Rule
- func OneOf(name string, allowed ...string) Rule
- func Required(name string) Rule
- func RequiredIf(name string, predicate func(v Values) bool) Rule
- type RuleFunc
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindFlagsFromStruct ¶
BindFlagsFromStruct declares flags based on struct tags. Supported tags: flag, usage, default
func LoadFromCobraFlags ¶
LoadFromCobraFlags reads values of flags defined on cmd according to `flag` tags on the fields of opts (a pointer to struct) and writes them into opts. Supported field kinds: string, bool.
func LoadFromViper ¶
LoadFromViper decodes viper keyspace into the struct. Flags are already bound.
func Preflight ¶
Preflight returns a PersistentPreRunE-compatible function that ensures login and, if zoneRequired, resolves zoneId via --default-zone or --zoneId flags with consistent error messages.
func SetDefaultZone ¶
SetDefaultZone sets the default zone ID and name in the config and writes it to disk.
func TokenFromContext ¶
func ZoneIDFromContext ¶
Types ¶
type CobraValues ¶
type CobraValues struct {
// contains filtered or unexported fields
}
func NewCobraValues ¶
func NewCobraValues(cmd *cobra.Command) CobraValues
func (CobraValues) Changed ¶
func (c CobraValues) Changed(name string) bool
func (CobraValues) GetBool ¶
func (c CobraValues) GetBool(name string) bool
func (CobraValues) GetString ¶
func (c CobraValues) GetString(name string) string
Click to show internal directories.
Click to hide internal directories.