cli

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ViperAddArgument

func ViperAddArgument(cmd *cobra.Command, a Argument) error

ViperAddArgument provides a data driven way to add cli arguments

func ViperAddArguments

func ViperAddArguments(cmd *cobra.Command, aList []Argument) error

ViperAddArguments allows you to pass in many argument configs

func ViperConfig

func ViperConfig(envPrefix, configName string) error

ViperConfig will help configure a project. This includes setting the environment variable prefix, plus the default config file name. For example:

cli.ViperConfig("ears")

func ViperConfigFile added in v1.1.0

func ViperConfigFile() string

ViperConfigFile is only for visibility/debugging so that the user knows exactly which config file is used

Types

type ArgType

type ArgType string
const (
	ArgTypeInt         ArgType = "int"
	ArgTypeIntSlice    ArgType = "[]int"
	ArgTypeFloat       ArgType = "float"
	ArgTypeFloatSlice  ArgType = "[]float"
	ArgTypeString      ArgType = "string"
	ArgTypeStringSlice ArgType = "[]string"
	ArgTypeBool        ArgType = "bool"
	ArgTypeBoolSlice   ArgType = "[]bool"
)

type Argument

type Argument struct {
	Name        string
	Shorthand   string
	Type        ArgType
	Description string
	Default     interface{}
	LookupKey   string
	Persistent  bool
}

type Config

type Config struct {
	EnvPrefix string
	Name      string
	Paths     []string
}

type ConfigError

type ConfigError struct {
	Err error
	// contains filtered or unexported fields
}

func (*ConfigError) Error

func (c *ConfigError) Error() string

func (*ConfigError) Unwrap

func (c *ConfigError) Unwrap() error

type ConfigNotSupportedProtocolError

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

func (*ConfigNotSupportedProtocolError) Error

type EmptyCmdArgumentError

type EmptyCmdArgumentError struct {
}

func (*EmptyCmdArgumentError) Error

func (e *EmptyCmdArgumentError) Error() string

type NoDefaultSetError

type NoDefaultSetError struct {
}

func (*NoDefaultSetError) Error

func (e *NoDefaultSetError) Error() string

Jump to

Keyboard shortcuts

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