mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Normalize the log for docker subcommand usage,
delete unecessary blank after "[OPTIONS] " and add a blank to the log between options and signature. To make the code style consistency. Signed-off-by: Zen Lin(Zhinan Lin) <linzhinan@huawei.com>
This commit is contained in:
parent
f63a29ddee
commit
2b051bcbda
2 changed files with 7 additions and 4 deletions
|
@ -93,10 +93,13 @@ func (cli *DockerCli) Subcmd(name, signature, description string, exitOnError bo
|
||||||
flags := flag.NewFlagSet(name, errorHandling)
|
flags := flag.NewFlagSet(name, errorHandling)
|
||||||
flags.Usage = func() {
|
flags.Usage = func() {
|
||||||
options := ""
|
options := ""
|
||||||
if flags.FlagCountUndeprecated() > 0 {
|
if signature != "" {
|
||||||
options = "[OPTIONS] "
|
signature = " " + signature
|
||||||
}
|
}
|
||||||
fmt.Fprintf(cli.out, "\nUsage: docker %s %s%s\n\n%s\n\n", name, options, signature, description)
|
if flags.FlagCountUndeprecated() > 0 {
|
||||||
|
options = " [OPTIONS]"
|
||||||
|
}
|
||||||
|
fmt.Fprintf(cli.out, "\nUsage: docker %s%s%s\n\n%s\n\n", name, options, signature, description)
|
||||||
flags.SetOutput(cli.out)
|
flags.SetOutput(cli.out)
|
||||||
flags.PrintDefaults()
|
flags.PrintDefaults()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
|
@ -130,7 +130,7 @@ func TestHelpTextVerify(t *testing.T) {
|
||||||
if strings.HasPrefix(line, " -") && strings.HasSuffix(line, ".") {
|
if strings.HasPrefix(line, " -") && strings.HasSuffix(line, ".") {
|
||||||
t.Fatalf("Help for %q should not end with a period: %s", cmd, line)
|
t.Fatalf("Help for %q should not end with a period: %s", cmd, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Options should not end with a space
|
// Options should not end with a space
|
||||||
if strings.HasSuffix(line, " ") {
|
if strings.HasSuffix(line, " ") {
|
||||||
t.Fatalf("Help for %q should not end with a space: %s", cmd, line)
|
t.Fatalf("Help for %q should not end with a space: %s", cmd, line)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue