Documentation
¶
Overview ¶
Package flag implements flag-related functionality.
Index ¶
- 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 GetApp(ctx context.Context) string
- func GetAppConfigFilePath(ctx context.Context) string
- func GetBool(ctx context.Context, name string) bool
- func GetBuildOnly(ctx context.Context) bool
- func GetDetach(ctx context.Context) bool
- func GetDuration(ctx context.Context, name string) time.Duration
- func GetFlagsName(ctx context.Context, ignoreFlags []string) []string
- func GetInt(ctx context.Context, name string) int
- func GetLocalOnly(ctx context.Context) bool
- func GetOrg(ctx context.Context) string
- func GetRegion(ctx context.Context) string
- func GetRemoteOnly(ctx context.Context) bool
- func GetString(ctx context.Context, name string) string
- func GetStringArray(ctx context.Context, name string) []string
- func GetStringSlice(ctx context.Context, name string) []string
- func GetYes(ctx context.Context) bool
- func IsSpecified(ctx context.Context, name string) bool
- func NewContext(ctx context.Context, fs *pflag.FlagSet) context.Context
- func SetString(ctx context.Context, name, value string) error
- type Bool
- type Duration
- type Flag
- type Int
- type Set
- type String
- type StringArray
- type StringSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(cmd *cobra.Command, flags ...Flag)
Add adds flag to cmd, binding them on v should v not be nil.
func FirstArg ¶
func FirstArg(ctx context.Context) string
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 ¶
func FromContext(ctx context.Context) *pflag.FlagSet
FromContext returns the FlagSet ctx carries. It panics in case ctx carries no FlagSet.
func GetAppConfigFilePath ¶
func GetAppConfigFilePath(ctx context.Context) string
GetAppConfigFilePath is shorthand for GetString(ctx, AppConfigFilePath).
func GetBool ¶
func GetBool(ctx context.Context, name string) bool
GetBool returns the value of the named boolean flag ctx carries.
func GetBuildOnly ¶
func GetBuildOnly(ctx context.Context) bool
func GetDuration ¶ added in v0.0.500
func GetDuration(ctx context.Context, name string) time.Duration
GetDuration returns the value of the named duration flag ctx carries.
func GetFlagsName ¶ added in v0.1.1
func GetFlagsName(ctx context.Context, ignoreFlags []string) []string
GetFlagsName returns the name of flags that have been set except unwanted flags.
func GetInt ¶
func GetInt(ctx context.Context, name string) int
GetInt returns the value of the named int flag ctx carries. It panics in case ctx carries no flags or in case the named flag isn't an int one.
func GetLocalOnly ¶
func GetLocalOnly(ctx context.Context) bool
func GetRegion ¶
func GetRegion(ctx context.Context) string
GetRegion is shorthand for GetString(ctx, Region).
func GetRemoteOnly ¶
func GetRemoteOnly(ctx context.Context) bool
func GetString ¶
func GetString(ctx context.Context, name string) string
GetString returns the value of the named string flag ctx carries.
func GetStringArray ¶ added in v0.1.1
func GetStringArray(ctx context.Context, name string) []string
GetStringArray returns the values of the named string flag ctx carries. Preserves commas (unlike the following `GetStringSlice`): in `--flag x,y` the value is string[]{`x,y`}. This is useful to pass key-value pairs like environment variables or build arguments.
func GetStringSlice ¶
func GetStringSlice(ctx context.Context, name string) []string
GetStringSlice returns the values of the named string flag ctx carries. Can be comma separated or passed "by repeated flags": `--flag x,y` is equivalent to `--flag x --flag y`.
func IsSpecified ¶ added in v0.0.475
func IsSpecified(ctx context.Context, name string) bool
IsSpecified returns whether a flag has been specified at all or not. This is useful, for example, when differentiating between 0/"" and unspecified.
func NewContext ¶
func NewContext(ctx context.Context, fs *pflag.FlagSet) context.Context
NewContext derives a context that carries fs from ctx.
Types ¶
type Bool ¶
type Bool struct {
Name string
Shorthand string
Description string
Default bool
Hidden bool
Aliases []string
}
Bool wraps the set of boolean flags.
func BuildOnly ¶
func BuildOnly() Bool
BuildOnly returns a boolean flag for building without a deployment
func GenerateName ¶
func GenerateName() Bool
GenerateName returns a boolean flag for generating an application name
func JSONOutput ¶ added in v0.0.519
func JSONOutput() Bool
func Push ¶ added in v0.0.311
func Push() Bool
Push returns a boolean flag to force pushing a build image to the registry
func RemoteOnly ¶
func RemoteOnly(defaultValue bool) Bool
RemoteOnly returns a boolean flag for deploying remotely
type Duration ¶ added in v0.0.500
type Duration struct {
Name string
Shorthand string
Description string
Default time.Duration
ConfName string
EnvName string
Hidden bool
Aliases []string
}
Duration wraps the set of duration flags.
type Flag ¶
type Flag interface {
// contains filtered or unexported methods
}
Flag wraps the set of flags.
type Int ¶
type Int struct {
Name string
Shorthand string
Description string
Default int
Hidden bool
Aliases []string
}
Int wraps the set of int flags.
type String ¶
type String struct {
Name string
Shorthand string
Description string
Default string
ConfName string
EnvName string
Hidden bool
Aliases []string
CompletionFn func(ctx context.Context, cmd *cobra.Command, args []string, partial string) ([]string, error)
}
String wraps the set of string flags.
func BuildTarget ¶ added in v0.0.337
func BuildTarget() String
func Dockerfile ¶ added in v0.0.335
func Dockerfile() String
func Ignorefile ¶ added in v0.0.433
func Ignorefile() String
func ImageLabel ¶ added in v0.0.337
func ImageLabel() String
type StringArray ¶ added in v0.1.1
type StringArray struct {
Name string
Shorthand string
Description string
Default []string
ConfName string
EnvName string
Hidden bool
Aliases []string
}
StringArray wraps the set of string array flags.
func BuildSecret ¶ added in v0.0.337
func BuildSecret() StringArray
type StringSlice ¶
type StringSlice struct {
Name string
Shorthand string
Description string
Default []string
ConfName string
EnvName string
Hidden bool
Aliases []string
}
StringSlice wraps the set of string slice flags.