summaryrefslogtreecommitdiff
path: root/pkg/mflag
diff options
context:
space:
mode:
authorunclejack <unclejack@users.noreply.github.com>2014-03-26 00:00:37 +0200
committerunclejack <unclejack@users.noreply.github.com>2014-03-26 00:00:37 +0200
commit867b2a90c228f62cdcd44907ceef279a2d8f1ac5 (patch)
treea41c506d3adefe00861f9e38155f5b21e1692ab4 /pkg/mflag
parent143c9707a9fafc39e1d9747f528db97b2564f01e (diff)
parent3600720a36929b1a51a227699a337cc593e2534d (diff)
downloaddocker-release-0.9.tar.gz
Merge pull request #4831 from unclejack/final_bump_v0.9.1v0.9.1release-0.9hotfix-0.9.2
Bump to version 0.9.1
Diffstat (limited to 'pkg/mflag')
-rw-r--r--pkg/mflag/example/example.go3
-rw-r--r--pkg/mflag/flag.go15
2 files changed, 15 insertions, 3 deletions
diff --git a/pkg/mflag/example/example.go b/pkg/mflag/example/example.go
index ed940e8d70..ce9dd30e4c 100644
--- a/pkg/mflag/example/example.go
+++ b/pkg/mflag/example/example.go
@@ -13,7 +13,8 @@ var (
func init() {
flag.Bool([]string{"#hp", "#-halp"}, false, "display the halp")
- flag.BoolVar(&b, []string{"b"}, false, "a simple bool")
+ flag.BoolVar(&b, []string{"b", "#bal", "#bol", "-bal"}, false, "a simple bool")
+ flag.BoolVar(&b, []string{"g", "#gil"}, false, "a simple bool")
flag.BoolVar(&b2, []string{"#-bool"}, false, "a simple bool")
flag.IntVar(&i, []string{"-integer", "-number"}, -1, "a simple integer")
flag.StringVar(&str, []string{"s", "#hidden", "-string"}, "", "a simple string") //-s -hidden and --string will work, but -hidden won't be in the usage
diff --git a/pkg/mflag/flag.go b/pkg/mflag/flag.go
index 7125c030ed..581041065c 100644
--- a/pkg/mflag/flag.go
+++ b/pkg/mflag/flag.go
@@ -805,9 +805,20 @@ func (f *FlagSet) parseOne() (bool, string, error) {
f.actual = make(map[string]*Flag)
}
f.actual[name] = flag
- for _, n := range flag.Names {
+ for i, n := range flag.Names {
if n == fmt.Sprintf("#%s", name) {
- fmt.Fprintf(f.out(), "Warning: '-%s' is deprecated, it will be removed soon. See usage.\n", name)
+ replacement := ""
+ for j := i; j < len(flag.Names); j++ {
+ if flag.Names[j][0] != '#' {
+ replacement = flag.Names[j]
+ break
+ }
+ }
+ if replacement != "" {
+ fmt.Fprintf(f.out(), "Warning: '-%s' is deprecated, it will be replaced by '-%s' soon. See usage.\n", name, replacement)
+ } else {
+ fmt.Fprintf(f.out(), "Warning: '-%s' is deprecated, it will be removed soon. See usage.\n", name)
+ }
}
}
return true, "", nil