aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/urfave/cli/flag.go
diff options
context:
space:
mode:
authorJoseph Richey <joerichey94@gmail.com>2017-09-29 02:08:56 -0700
committerJoseph Richey <joerichey94@gmail.com>2017-09-29 02:33:45 -0700
commit05911d5503434a802c6dc9909a74cc76c2bf6661 (patch)
treee1e7aa0ba09dcc4b4c56b28429d1f6f288bba03b /vendor/github.com/urfave/cli/flag.go
parenta949b13dac670014c37c7181e368b9c0c7a7f0f5 (diff)
vendor: Update to latest versions
This changes the vendored sources of github.com/golang/protobuf, golang.org/x/crypto/ssh, and golang.org/x/sys/unix to be the current master versions.
Diffstat (limited to 'vendor/github.com/urfave/cli/flag.go')
-rw-r--r--vendor/github.com/urfave/cli/flag.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/vendor/github.com/urfave/cli/flag.go b/vendor/github.com/urfave/cli/flag.go
index 877ff35..b17f5b9 100644
--- a/vendor/github.com/urfave/cli/flag.go
+++ b/vendor/github.com/urfave/cli/flag.go
@@ -37,6 +37,14 @@ var HelpFlag Flag = BoolFlag{
// to display a flag.
var FlagStringer FlagStringFunc = stringifyFlag
+// FlagNamePrefixer converts a full flag name and its placeholder into the help
+// message flag prefix. This is used by the default FlagStringer.
+var FlagNamePrefixer FlagNamePrefixFunc = prefixedNames
+
+// FlagEnvHinter annotates flag help message with the environment variable
+// details. This is used by the default FlagStringer.
+var FlagEnvHinter FlagEnvHintFunc = withEnvHint
+
// FlagsByName is a slice of Flag.
type FlagsByName []Flag
@@ -710,13 +718,13 @@ func stringifyFlag(f Flag) string {
switch f.(type) {
case IntSliceFlag:
- return withEnvHint(fv.FieldByName("EnvVar").String(),
+ return FlagEnvHinter(fv.FieldByName("EnvVar").String(),
stringifyIntSliceFlag(f.(IntSliceFlag)))
case Int64SliceFlag:
- return withEnvHint(fv.FieldByName("EnvVar").String(),
+ return FlagEnvHinter(fv.FieldByName("EnvVar").String(),
stringifyInt64SliceFlag(f.(Int64SliceFlag)))
case StringSliceFlag:
- return withEnvHint(fv.FieldByName("EnvVar").String(),
+ return FlagEnvHinter(fv.FieldByName("EnvVar").String(),
stringifyStringSliceFlag(f.(StringSliceFlag)))
}
@@ -744,8 +752,8 @@ func stringifyFlag(f Flag) string {
usageWithDefault := strings.TrimSpace(fmt.Sprintf("%s%s", usage, defaultValueString))
- return withEnvHint(fv.FieldByName("EnvVar").String(),
- fmt.Sprintf("%s\t%s", prefixedNames(fv.FieldByName("Name").String(), placeholder), usageWithDefault))
+ return FlagEnvHinter(fv.FieldByName("EnvVar").String(),
+ fmt.Sprintf("%s\t%s", FlagNamePrefixer(fv.FieldByName("Name").String(), placeholder), usageWithDefault))
}
func stringifyIntSliceFlag(f IntSliceFlag) string {
@@ -795,5 +803,5 @@ func stringifySliceFlag(usage, name string, defaultVals []string) string {
}
usageWithDefault := strings.TrimSpace(fmt.Sprintf("%s%s", usage, defaultVal))
- return fmt.Sprintf("%s\t%s", prefixedNames(name, placeholder), usageWithDefault)
+ return fmt.Sprintf("%s\t%s", FlagNamePrefixer(name, placeholder), usageWithDefault)
}