Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
| ... | ... |
@@ -13,7 +13,8 @@ var ( |
| 13 | 13 |
|
| 14 | 14 |
func init() {
|
| 15 | 15 |
flag.Bool([]string{"#hp", "#-halp"}, false, "display the halp")
|
| 16 |
- flag.BoolVar(&b, []string{"b"}, false, "a simple bool")
|
|
| 16 |
+ flag.BoolVar(&b, []string{"b", "#bal", "#bol", "-bal"}, false, "a simple bool")
|
|
| 17 |
+ flag.BoolVar(&b, []string{"g", "#gil"}, false, "a simple bool")
|
|
| 17 | 18 |
flag.BoolVar(&b2, []string{"#-bool"}, false, "a simple bool")
|
| 18 | 19 |
flag.IntVar(&i, []string{"-integer", "-number"}, -1, "a simple integer")
|
| 19 | 20 |
flag.StringVar(&str, []string{"s", "#hidden", "-string"}, "", "a simple string") //-s -hidden and --string will work, but -hidden won't be in the usage
|
| ... | ... |
@@ -820,9 +820,20 @@ func (f *FlagSet) parseOne() (bool, string, error) {
|
| 820 | 820 |
f.actual = make(map[string]*Flag) |
| 821 | 821 |
} |
| 822 | 822 |
f.actual[name] = flag |
| 823 |
- for _, n := range flag.Names {
|
|
| 823 |
+ for i, n := range flag.Names {
|
|
| 824 | 824 |
if n == fmt.Sprintf("#%s", name) {
|
| 825 |
- fmt.Fprintf(f.out(), "Warning: '-%s' is deprecated, it will be removed soon. See usage.\n", name) |
|
| 825 |
+ replacement := "" |
|
| 826 |
+ for j := i; j < len(flag.Names); j++ {
|
|
| 827 |
+ if flag.Names[j][0] != '#' {
|
|
| 828 |
+ replacement = flag.Names[j] |
|
| 829 |
+ break |
|
| 830 |
+ } |
|
| 831 |
+ } |
|
| 832 |
+ if replacement != "" {
|
|
| 833 |
+ fmt.Fprintf(f.out(), "Warning: '-%s' is deprecated, it will be replaced by '-%s' soon. See usage.\n", name, replacement) |
|
| 834 |
+ } else {
|
|
| 835 |
+ fmt.Fprintf(f.out(), "Warning: '-%s' is deprecated, it will be removed soon. See usage.\n", name) |
|
| 836 |
+ } |
|
| 826 | 837 |
} |
| 827 | 838 |
} |
| 828 | 839 |
return true, "", nil |