cmdconfig

package
v1.0.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: AGPL-3.0 Imports: 42 Imported by: 1

Documentation

Overview

Package cmd_config contains helper functions to support constructing Cobra commands, validating arguments and populating Viper config management

Index

Constants

This section is empty.

Variables

View Source
var FlagOptions = struct {
	Required      func() FlagOption
	Hidden        func() FlagOption
	Deprecated    func(string) FlagOption
	NoOptDefVal   func(string) FlagOption
	WithShortHand func(string) FlagOption
}{
	Required:      requiredOpt,
	Hidden:        hiddenOpt,
	Deprecated:    deprecatedOpt,
	NoOptDefVal:   noOptDefValOpt,
	WithShortHand: withShortHand,
}

FlagOptions - shortcut for common flag options

Functions

func DisplayConfig added in v0.17.0

func DisplayConfig()

DisplayConfig prints all config set via WorkspaceProfile or HCL options

func SetAppSpecificConstants added in v1.0.0

func SetAppSpecificConstants()

SetAppSpecificConstants sets app specific constants defined in pipe-fittings

func SetDefaultFromEnv added in v0.17.0

func SetDefaultFromEnv(k string, configVar string, varType EnvVarType)

func SetDefaultsFromConfig added in v0.17.0

func SetDefaultsFromConfig(configMap map[string]interface{})

SetDefaultsFromConfig overrides viper default values from hcl config values

func ValidateSnapshotArgs added in v0.17.0

func ValidateSnapshotArgs(ctx context.Context) error

func Viper

func Viper() *viper.Viper

Viper fetches the global viper instance

Types

type CmdBuilder

type CmdBuilder struct {
	// contains filtered or unexported fields
}

func OnCmd

func OnCmd(cmd *cobra.Command) *CmdBuilder

OnCmd starts a config builder wrapping over the provided *cobra.Command

func (*CmdBuilder) AddBoolFlag

func (c *CmdBuilder) AddBoolFlag(name string, defaultValue bool, desc string, opts ...FlagOption) *CmdBuilder

AddBoolFlag ia s helper function to add a boolean flag to a command

func (*CmdBuilder) AddCloudFlags added in v0.21.0

func (c *CmdBuilder) AddCloudFlags() *CmdBuilder

AddCloudFlags is helper function to add the cloud flags to a command

func (*CmdBuilder) AddIntFlag

func (c *CmdBuilder) AddIntFlag(name string, defaultValue int, desc string, opts ...FlagOption) *CmdBuilder

AddIntFlag is a helper function to add an integer flag to a command

func (*CmdBuilder) AddStringArrayFlag

func (c *CmdBuilder) AddStringArrayFlag(name string, defaultValue []string, desc string, opts ...FlagOption) *CmdBuilder

AddStringArrayFlag is a helper function to add a flag that accepts an array of strings

func (*CmdBuilder) AddStringFlag

func (c *CmdBuilder) AddStringFlag(name string, defaultValue string, desc string, opts ...FlagOption) *CmdBuilder

AddStringFlag is a helper function to add a string flag to a command

func (*CmdBuilder) AddStringMapStringFlag

func (c *CmdBuilder) AddStringMapStringFlag(name string, defaultValue map[string]string, desc string, opts ...FlagOption) *CmdBuilder

AddStringMapStringFlag is a helper function to add a flag that accepts a map of strings

func (*CmdBuilder) AddStringSliceFlag

func (c *CmdBuilder) AddStringSliceFlag(name string, defaultValue []string, desc string, opts ...FlagOption) *CmdBuilder

AddStringSliceFlag is a helper function to add a flag that accepts an array of strings

func (*CmdBuilder) AddVarFlag added in v0.23.0

func (c *CmdBuilder) AddVarFlag(value pflag.Value, name string, usage string, opts ...FlagOption) *CmdBuilder

func (*CmdBuilder) AddWorkspaceDatabaseFlag added in v0.21.0

func (c *CmdBuilder) AddWorkspaceDatabaseFlag() *CmdBuilder

AddWorkspaceDatabaseFlag is helper function to add the workspace-databse flag to a command

type EnvVarType added in v0.20.0

type EnvVarType int
const (
	String EnvVarType = iota
	Int
	Bool
)

func (EnvVarType) String added in v0.20.0

func (i EnvVarType) String() string

type FlagOption added in v0.23.0

type FlagOption func(c *cobra.Command, name string, key string)

Jump to

Keyboard shortcuts

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