From 8855da61118b1ea9e641b36da15b6253f0342e72 Mon Sep 17 00:00:00 2001 From: "Zen Lin(Zhinan Lin)" Date: Wed, 11 Mar 2015 18:46:01 +0800 Subject: [PATCH 1/3] Add the check for suffix of option in each line of help, to make sure no extra space in it Signed-off-by: Zen Lin(Zhinan Lin) Upstream-commit: f63a29ddeee62c8e4fcb1cf8eaf84aff305380c0 Component: engine --- components/engine/integration-cli/docker_cli_help_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/engine/integration-cli/docker_cli_help_test.go b/components/engine/integration-cli/docker_cli_help_test.go index 1c83204244..c48fbafc43 100644 --- a/components/engine/integration-cli/docker_cli_help_test.go +++ b/components/engine/integration-cli/docker_cli_help_test.go @@ -130,6 +130,11 @@ func TestHelpTextVerify(t *testing.T) { if strings.HasPrefix(line, " -") && strings.HasSuffix(line, ".") { t.Fatalf("Help for %q should not end with a period: %s", cmd, line) } + + // Options should not end with a space + if strings.HasSuffix(line, " ") { + t.Fatalf("Help for %q should not end with a space: %s", cmd, line) + } } } From 362dc0b239221afa597c5fe8e88fba9a9c536a76 Mon Sep 17 00:00:00 2001 From: "Zen Lin(Zhinan Lin)" Date: Wed, 11 Mar 2015 18:48:57 +0800 Subject: [PATCH 2/3] 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) Upstream-commit: 2b051bcbda06ec48287e75da506bacf95be2b652 Component: engine --- components/engine/api/client/cli.go | 9 ++++++--- .../engine/integration-cli/docker_cli_help_test.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/components/engine/api/client/cli.go b/components/engine/api/client/cli.go index 4c5eb2d0d6..fcf6c033fb 100644 --- a/components/engine/api/client/cli.go +++ b/components/engine/api/client/cli.go @@ -93,10 +93,13 @@ func (cli *DockerCli) Subcmd(name, signature, description string, exitOnError bo flags := flag.NewFlagSet(name, errorHandling) flags.Usage = func() { options := "" - if flags.FlagCountUndeprecated() > 0 { - options = "[OPTIONS] " + if signature != "" { + 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.PrintDefaults() os.Exit(0) diff --git a/components/engine/integration-cli/docker_cli_help_test.go b/components/engine/integration-cli/docker_cli_help_test.go index c48fbafc43..4ef8b7bd9e 100644 --- a/components/engine/integration-cli/docker_cli_help_test.go +++ b/components/engine/integration-cli/docker_cli_help_test.go @@ -130,7 +130,7 @@ func TestHelpTextVerify(t *testing.T) { if strings.HasPrefix(line, " -") && strings.HasSuffix(line, ".") { t.Fatalf("Help for %q should not end with a period: %s", cmd, line) } - + // Options should not end with a space if strings.HasSuffix(line, " ") { t.Fatalf("Help for %q should not end with a space: %s", cmd, line) From 8ea0c3c94e107b33b436c795085ceca015963a12 Mon Sep 17 00:00:00 2001 From: "Zen Lin(Zhinan Lin)" Date: Wed, 11 Mar 2015 21:11:15 +0800 Subject: [PATCH 3/3] Add checking trailing space for all lines of the help output Signed-off-by: Zen Lin(Zhinan Lin) Upstream-commit: 491b63e0daa9103cf9471c03c4b41026f6955323 Component: engine --- components/engine/integration-cli/docker_cli_help_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/engine/integration-cli/docker_cli_help_test.go b/components/engine/integration-cli/docker_cli_help_test.go index 4ef8b7bd9e..8fc5cd1aab 100644 --- a/components/engine/integration-cli/docker_cli_help_test.go +++ b/components/engine/integration-cli/docker_cli_help_test.go @@ -59,6 +59,11 @@ func TestHelpTextVerify(t *testing.T) { t.Fatalf("Line is too long(%d chars):\n%s", len(line), line) } + // All lines should not end with a space + if strings.HasSuffix(line, " ") { + t.Fatalf("Line should not end with a space: %s", line) + } + if scanForHome && strings.Contains(line, `=`+home) { t.Fatalf("Line should use '%q' instead of %q:\n%s", homedir.GetShortcutString(), home, line) } @@ -131,10 +136,11 @@ func TestHelpTextVerify(t *testing.T) { 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, " ") { t.Fatalf("Help for %q should not end with a space: %s", cmd, line) } + } }