Documentation
¶
Index ¶
- func Init(cobraCommand *cobra.Command, contextVariables ContextVariables)
- func InitBools(cobraCommand *cobra.Command, contextBools []ContextBool)
- func InitInts(cobraCommand *cobra.Command, contextInts []ContextInt)
- func InitStringSlices(cobraCommand *cobra.Command, contextStringSlices []ContextStringSlice)
- func InitStrings(cobraCommand *cobra.Command, contextStrings []ContextString)
- func OsLookupEnvBool(envar string, aDefault bool) bool
- func OsLookupEnvInt(envar string, aDefault int) int
- func OsLookupEnvString(envar string, aDefault string) string
- func PreRun(cobraCommand *cobra.Command, args []string, configName string, ...)
- func Version(version string, iteration string) string
- type ContextBool
- type ContextInt
- type ContextString
- type ContextStringSlice
- type ContextVariables
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(cobraCommand *cobra.Command, contextVariables ContextVariables)
Example ¶
cobraCommand := &cobra.Command{
Use: "example-use",
Short: "example-short",
Long: `example-long`,
}
var contextVariables = ContextVariables{
Strings: []ContextString{
{
Default: "",
Envar: "MY_VARIABLE",
Help: "Description of my variable [%s]",
Option: "my-variable",
},
},
}
Init(cobraCommand, contextVariables)
func InitBools ¶
func InitBools(cobraCommand *cobra.Command, contextBools []ContextBool)
func InitInts ¶
func InitInts(cobraCommand *cobra.Command, contextInts []ContextInt)
func InitStringSlices ¶
func InitStringSlices(cobraCommand *cobra.Command, contextStringSlices []ContextStringSlice)
func InitStrings ¶
func InitStrings(cobraCommand *cobra.Command, contextStrings []ContextString)
func OsLookupEnvBool ¶
Example ¶
fmt.Println(OsLookupEnvBool("NOT_AN_ENVIRONMENT_VARIABLE", true))
Output: true
func OsLookupEnvInt ¶
Example ¶
fmt.Println(OsLookupEnvInt("NOT_AN_ENVIRONMENT_VARIABLE", 10))
Output: 10
func OsLookupEnvString ¶
Example ¶
fmt.Println(OsLookupEnvString("NOT_AN_ENVIRONMENT_VARIABLE", "default"))
Output: default
func PreRun ¶
func PreRun(cobraCommand *cobra.Command, args []string, configName string, contextVariables ContextVariables)
Example ¶
cobraCommand := &cobra.Command{
Use: "example-use",
Short: "example-short",
Long: `example-long`,
}
var contextVariables = ContextVariables{
Strings: []ContextString{
{
Default: "",
Envar: "MY_VARIABLE",
Help: "Description of my variable [%s]",
Option: "my-variable",
},
},
}
Init(cobraCommand, contextVariables)
PreRun(cobraCommand, []string{}, "example-cmd", contextVariables)
Types ¶
type ContextBool ¶
type ContextInt ¶
type ContextString ¶
type ContextStringSlice ¶
type ContextVariables ¶
type ContextVariables struct {
Bools []ContextBool `json:"bools"`
Ints []ContextInt `json:"ints"`
Strings []ContextString `json:"strings"`
StringSlices []ContextStringSlice `json:"stringSlices"`
}
Click to show internal directories.
Click to hide internal directories.