flags

package
v3.16.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package flags is a simple cobra/viper-aware flag wrapper that creates a unified interface for flag addition and access. It supports only the types that iscenv needs, if you need more add them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConfigFlag

func AddConfigFlag(cmd *cobra.Command, name string, value interface{}, usage string)

AddConfigFlag adds a flag to the provided command that is also bound to a config value

func AddConfigFlagP

func AddConfigFlagP(cmd *cobra.Command, name string, shorthand string, value interface{}, usage string)

AddConfigFlagP is like AddConfigFlag but accepts a shorthand letter that can be used after a single dash.

func AddFlag

func AddFlag(cmd *cobra.Command, name string, value interface{}, usage string)

AddFlag adds a flag to the provided command

func AddFlagComplex

func AddFlagComplex(cmd *cobra.Command, persistent bool, cfg bool, name string, shorthand string, value interface{}, usage string)

AddFlagComplex adds a flag to the provided cobra command. The default value will determine the type of flag. Supported types are: string, bool, int64, uint, []string

func AddFlagP

func AddFlagP(cmd *cobra.Command, name string, shorthand string, value interface{}, usage string)

AddFlagP is like AddFlag, but accepts a shorthand letter that can be used after a single dash

func GetBool

func GetBool(cmd *cobra.Command, name string) bool

GetBool returns a flag value by name as a bool

func GetFlagKey

func GetFlagKey(cmd *cobra.Command, name string) string

GetFlagKey returns the key for a flag given its name

func GetInt

func GetInt(cmd *cobra.Command, name string) int

GetInt returns a flag value by name as a int

func GetInt64

func GetInt64(cmd *cobra.Command, name string) int64

GetInt64 returns a flag value by name as a int64

func GetKeys

func GetKeys() []string

GetKeys returns a slice of the keys of the flags

func GetRawValue

func GetRawValue(key string) interface{}

GetRawValue returns a flag value as the underlying interface without asserting a type

func GetString

func GetString(cmd *cobra.Command, name string) string

GetString returns a flag value by name as a string

func GetStringSlice

func GetStringSlice(cmd *cobra.Command, name string) []string

GetStringSlice returns a flag value by name as a string slice

func GetUint

func GetUint(cmd *cobra.Command, name string) uint

GetUint returns a flag value by name as a uint

func GetValue

func GetValue(cmd *cobra.Command, name string) interface{}

GetValue returns a flag value by name as an interface

func GetValueWithKey

func GetValueWithKey(key string) interface{}

GetValueWithKey returns a flag value by key as an interface

Types

This section is empty.

Jump to

Keyboard shortcuts

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