Hide deprecated shorthand in man page

This commit is contained in:
feihujiang
2015-10-14 08:34:22 +08:00
parent dfb400e2e9
commit f3673b8f31
9 changed files with 15 additions and 11 deletions

View File

@@ -78,12 +78,16 @@ func printFlags(out *bytes.Buffer, flags *pflag.FlagSet) {
// put quotes on the value
format = "**--%s**=%q\n\t%s\n\n"
}
if len(flag.Shorthand) > 0 {
// Todo, when we mark a shorthand is deprecated, but specify an empty message.
// The flag.ShorthandDeprecated is empty as the shorthand is deprecated.
// Using len(flag.ShorthandDeprecated) > 0 can't handle this, others are ok.
if !(len(flag.ShorthandDeprecated) > 0) && len(flag.Shorthand) > 0 {
format = "**-%s**, " + format
fmt.Fprintf(out, format, flag.Shorthand, flag.Name, flag.DefValue, flag.Usage)
} else {
format = "%s" + format
fmt.Fprintf(out, format, flag.Name, flag.DefValue, flag.Usage)
}
fmt.Fprintf(out, format, flag.Shorthand, flag.Name, flag.DefValue, flag.Usage)
})
}