Documentation ¶
Overview ¶
Package flag implements flag-related functionality.
Index ¶
- Constants
- func Add(cmd *cobra.Command, flags ...Flag)
- func Args(ctx context.Context) []string
- func FirstArg(ctx context.Context) string
- func FromContext(ctx context.Context) *pflag.FlagSet
- func GetBool(ctx context.Context, name string) bool
- func GetOrg(ctx context.Context) string
- func GetString(ctx context.Context, name string) string
- func GetYes(ctx context.Context) bool
- func NewContext(ctx context.Context, fs *pflag.FlagSet) context.Context
- type Bool
- type Flag
- type Int
- type String
- type StringSlice
Constants ¶
View Source
const ( // AccessTokenName denotes the name of the access token flag. AccessTokenName = "access-token" // VerboseName denotes the name of the verbose flag. VerboseName = "verbose" // JSONOutputName denotes the name of the json output flag. JSONOutputName = "json" // LocalOnlyName denotes the name of the local-only flag. LocalOnlyName = "local-only" // OrgName denotes the name of the org flag. OrgName = "org" // YesName denotes the name of the yes flag. YesName = "yes" )
Variables ¶
This section is empty.
Functions ¶
func FirstArg ¶
FirstArg returns the first arg ctx carries or an empty string in case ctx carries an empty argument set. It panics in case ctx carries no FlagSet.
func FromContext ¶
FromContext returns the FlagSet ctx carries. It panics in case ctx carries no FlagSet.
func GetBool ¶
GetBool returns the value of the named boolean flag ctx carries. It panics in case ctx carries no flags or in case the named flag isn't a boolean one.
func GetString ¶
GetString returns the value of the named string flag ctx carries. It panics in case ctx carries no flags or in case the named flag isn't a string one.
Types ¶
type Flag ¶
type Flag interface {
// contains filtered or unexported methods
}
Flag wraps the set of flags.
Click to show internal directories.
Click to hide internal directories.