Kaynağa Gözat

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>

Zen Lin(Zhinan Lin) 10 yıl önce
ebeveyn
işleme
2b051bcbda
2 değiştirilmiş dosya ile 6 ekleme ve 3 silme
  1. 5 2
      api/client/cli.go
  2. 1 1
      integration-cli/docker_cli_help_test.go

+ 5 - 2
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 signature != "" {
+			signature = " " + signature
+		}
 		if flags.FlagCountUndeprecated() > 0 {
-			options = "[OPTIONS] "
+			options = " [OPTIONS]"
 		}
-		fmt.Fprintf(cli.out, "\nUsage: docker %s %s%s\n\n%s\n\n", name, options, signature, description)
+		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)

+ 1 - 1
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)