Browse code

Revert "--help option and help command should print to stdout not stderr"

This reverts commit 61b129d81802e3c988cc0e67e488b24968dd748a.

Signed-off-by: Victor Vieux <vieux@docker.com>

Victor Vieux authored on 2014/08/28 03:59:13
Showing 38 changed files
... ...
@@ -52,8 +52,8 @@ func (cli *DockerCli) Cmd(args ...string) error {
52 52
 	if len(args) > 0 {
53 53
 		method, exists := cli.getMethod(args[0])
54 54
 		if !exists {
55
-			fmt.Fprintf(cli.err, "docker: '%s' is not a docker command. See 'docker --help'.\n", args[0])
56
-			os.Exit(1)
55
+			fmt.Println("Error: Command not found:", args[0])
56
+			return cli.CmdHelp(args[1:]...)
57 57
 		}
58 58
 		return method(args[1:]...)
59 59
 	}
... ...
@@ -63,10 +63,9 @@ func (cli *DockerCli) Cmd(args ...string) error {
63 63
 func (cli *DockerCli) Subcmd(name, signature, description string) *flag.FlagSet {
64 64
 	flags := flag.NewFlagSet(name, flag.ContinueOnError)
65 65
 	flags.Usage = func() {
66
-		fmt.Fprintf(cli.out, "\nUsage: docker %s %s\n\n%s\n\n", name, signature, description)
67
-		flags.SetOutput(cli.out)
66
+		fmt.Fprintf(cli.err, "\nUsage: docker %s %s\n\n%s\n\n", name, signature, description)
68 67
 		flags.PrintDefaults()
69
-		os.Exit(0)
68
+		os.Exit(2)
70 69
 	}
71 70
 	return flags
72 71
 }
... ...
@@ -48,8 +48,6 @@ func (cli *DockerCli) CmdHelp(args ...string) error {
48 48
 		method, exists := cli.getMethod(args[0])
49 49
 		if !exists {
50 50
 			fmt.Fprintf(cli.err, "Error: Command not found: %s\n", args[0])
51
-			fmt.Fprintf(cli.err, "docker: '%s' is not a docker command. See 'docker --help'.\n", args[0])
52
-			os.Exit(1)
53 51
 		} else {
54 52
 			method("--help")
55 53
 			return nil
... ...
@@ -95,7 +93,7 @@ func (cli *DockerCli) CmdHelp(args ...string) error {
95 95
 	} {
96 96
 		help += fmt.Sprintf("    %-10.10s%s\n", command[0], command[1])
97 97
 	}
98
-	fmt.Fprintf(cli.out, "%s\n", help)
98
+	fmt.Fprintf(cli.err, "%s\n", help)
99 99
 	return nil
100 100
 }
101 101
 
... ...
@@ -106,18 +104,13 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
106 106
 	noCache := cmd.Bool([]string{"#no-cache", "-no-cache"}, false, "Do not use cache when building the image")
107 107
 	rm := cmd.Bool([]string{"#rm", "-rm"}, true, "Remove intermediate containers after a successful build")
108 108
 	forceRm := cmd.Bool([]string{"-force-rm"}, false, "Always remove intermediate containers, even after unsuccessful builds")
109
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
110
-
111 109
 	if err := cmd.Parse(args); err != nil {
112 110
 		return nil
113 111
 	}
114
-	if *help {
112
+	if cmd.NArg() != 1 {
115 113
 		cmd.Usage()
116 114
 		return nil
117 115
 	}
118
-	if cmd.BadArgs(1) {
119
-		os.Exit(1)
120
-	}
121 116
 
122 117
 	var (
123 118
 		context  archive.Archive
... ...
@@ -269,16 +262,10 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
269 269
 	cmd.StringVar(&username, []string{"u", "-username"}, "", "Username")
270 270
 	cmd.StringVar(&password, []string{"p", "-password"}, "", "Password")
271 271
 	cmd.StringVar(&email, []string{"e", "-email"}, "", "Email")
272
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
273
-
274 272
 	err := cmd.Parse(args)
275 273
 	if err != nil {
276 274
 		return nil
277 275
 	}
278
-	if *help {
279
-		cmd.Usage()
280
-		return nil
281
-	}
282 276
 	serverAddress := registry.IndexServerAddress()
283 277
 	if len(cmd.Args()) > 0 {
284 278
 		serverAddress = cmd.Arg(0)
... ...
@@ -398,18 +385,13 @@ func (cli *DockerCli) CmdLogout(args ...string) error {
398 398
 // 'docker wait': block until a container stops
399 399
 func (cli *DockerCli) CmdWait(args ...string) error {
400 400
 	cmd := cli.Subcmd("wait", "CONTAINER [CONTAINER...]", "Block until a container stops, then print its exit code.")
401
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
402
-
403 401
 	if err := cmd.Parse(args); err != nil {
404 402
 		return nil
405 403
 	}
406
-	if *help {
404
+	if cmd.NArg() < 1 {
407 405
 		cmd.Usage()
408 406
 		return nil
409 407
 	}
410
-	if cmd.BadArgs(1) {
411
-		os.Exit(1)
412
-	}
413 408
 	var encounteredError error
414 409
 	for _, name := range cmd.Args() {
415 410
 		status, err := waitForExit(cli, name)
... ...
@@ -429,8 +411,10 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
429 429
 	if err := cmd.Parse(args); err != nil {
430 430
 		return nil
431 431
 	}
432
-	if cmd.BadArgs(0) {
433
-		os.Exit(1)
432
+
433
+	if cmd.NArg() > 0 {
434
+		cmd.Usage()
435
+		return nil
434 436
 	}
435 437
 	if dockerversion.VERSION != "" {
436 438
 		fmt.Fprintf(cli.out, "Client version: %s\n", dockerversion.VERSION)
... ...
@@ -473,8 +457,9 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
473 473
 	if err := cmd.Parse(args); err != nil {
474 474
 		return nil
475 475
 	}
476
-	if cmd.BadArgs(0) {
477
-		os.Exit(1)
476
+	if cmd.NArg() > 0 {
477
+		cmd.Usage()
478
+		return nil
478 479
 	}
479 480
 
480 481
 	body, _, err := readBody(cli.call("GET", "/info", nil, false))
... ...
@@ -546,18 +531,13 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
546 546
 func (cli *DockerCli) CmdStop(args ...string) error {
547 547
 	cmd := cli.Subcmd("stop", "[OPTIONS] CONTAINER [CONTAINER...]", "Stop a running container by sending SIGTERM and then SIGKILL after a grace period")
548 548
 	nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Number of seconds to wait for the container to stop before killing it. Default is 10 seconds.")
549
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
550
-
551 549
 	if err := cmd.Parse(args); err != nil {
552 550
 		return nil
553 551
 	}
554
-	if *help {
552
+	if cmd.NArg() < 1 {
555 553
 		cmd.Usage()
556 554
 		return nil
557 555
 	}
558
-	if cmd.BadArgs(1) {
559
-		os.Exit(1)
560
-	}
561 556
 
562 557
 	v := url.Values{}
563 558
 	v.Set("t", strconv.Itoa(*nSeconds))
... ...
@@ -578,18 +558,13 @@ func (cli *DockerCli) CmdStop(args ...string) error {
578 578
 func (cli *DockerCli) CmdRestart(args ...string) error {
579 579
 	cmd := cli.Subcmd("restart", "[OPTIONS] CONTAINER [CONTAINER...]", "Restart a running container")
580 580
 	nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default is 10 seconds.")
581
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
582
-
583 581
 	if err := cmd.Parse(args); err != nil {
584 582
 		return nil
585 583
 	}
586
-	if *help {
584
+	if cmd.NArg() < 1 {
587 585
 		cmd.Usage()
588 586
 		return nil
589 587
 	}
590
-	if cmd.BadArgs(1) {
591
-		os.Exit(1)
592
-	}
593 588
 
594 589
 	v := url.Values{}
595 590
 	v.Set("t", strconv.Itoa(*nSeconds))
... ...
@@ -641,19 +616,15 @@ func (cli *DockerCli) CmdStart(args ...string) error {
641 641
 		cmd       = cli.Subcmd("start", "CONTAINER [CONTAINER...]", "Restart a stopped container")
642 642
 		attach    = cmd.Bool([]string{"a", "-attach"}, false, "Attach container's STDOUT and STDERR and forward all signals to the process")
643 643
 		openStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Attach container's STDIN")
644
-		help      = cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
645 644
 	)
646 645
 
647 646
 	if err := cmd.Parse(args); err != nil {
648 647
 		return nil
649 648
 	}
650
-	if *help {
649
+	if cmd.NArg() < 1 {
651 650
 		cmd.Usage()
652 651
 		return nil
653 652
 	}
654
-	if cmd.BadArgs(1) {
655
-		os.Exit(1)
656
-	}
657 653
 
658 654
 	if *attach || *openStdin {
659 655
 		if cmd.NArg() > 1 {
... ...
@@ -733,8 +704,10 @@ func (cli *DockerCli) CmdUnpause(args ...string) error {
733 733
 	if err := cmd.Parse(args); err != nil {
734 734
 		return nil
735 735
 	}
736
-	if cmd.BadArgs(1) {
737
-		os.Exit(1)
736
+
737
+	if cmd.NArg() != 1 {
738
+		cmd.Usage()
739
+		return nil
738 740
 	}
739 741
 
740 742
 	var encounteredError error
... ...
@@ -754,8 +727,10 @@ func (cli *DockerCli) CmdPause(args ...string) error {
754 754
 	if err := cmd.Parse(args); err != nil {
755 755
 		return nil
756 756
 	}
757
-	if cmd.BadArgs(1) {
758
-		os.Exit(1)
757
+
758
+	if cmd.NArg() != 1 {
759
+		cmd.Usage()
760
+		return nil
759 761
 	}
760 762
 
761 763
 	var encounteredError error
... ...
@@ -773,18 +748,13 @@ func (cli *DockerCli) CmdPause(args ...string) error {
773 773
 func (cli *DockerCli) CmdInspect(args ...string) error {
774 774
 	cmd := cli.Subcmd("inspect", "CONTAINER|IMAGE [CONTAINER|IMAGE...]", "Return low-level information on a container or image")
775 775
 	tmplStr := cmd.String([]string{"f", "#format", "-format"}, "", "Format the output using the given go template.")
776
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
777
-
778 776
 	if err := cmd.Parse(args); err != nil {
779 777
 		return nil
780 778
 	}
781
-	if *help {
779
+	if cmd.NArg() < 1 {
782 780
 		cmd.Usage()
783 781
 		return nil
784 782
 	}
785
-	if cmd.BadArgs(1) {
786
-		os.Exit(1)
787
-	}
788 783
 
789 784
 	var tmpl *template.Template
790 785
 	if *tmplStr != "" {
... ...
@@ -857,18 +827,13 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
857 857
 
858 858
 func (cli *DockerCli) CmdTop(args ...string) error {
859 859
 	cmd := cli.Subcmd("top", "CONTAINER [ps OPTIONS]", "Display the running processes of a container")
860
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
861
-
862 860
 	if err := cmd.Parse(args); err != nil {
863 861
 		return nil
864 862
 	}
865
-	if *help {
863
+	if cmd.NArg() == 0 {
866 864
 		cmd.Usage()
867 865
 		return nil
868 866
 	}
869
-	if cmd.BadArgs(1) {
870
-		os.Exit(1)
871
-	}
872 867
 	val := url.Values{}
873 868
 	if cmd.NArg() > 1 {
874 869
 		val.Set("ps_args", strings.Join(cmd.Args()[1:], " "))
... ...
@@ -897,17 +862,13 @@ func (cli *DockerCli) CmdTop(args ...string) error {
897 897
 
898 898
 func (cli *DockerCli) CmdPort(args ...string) error {
899 899
 	cmd := cli.Subcmd("port", "CONTAINER PRIVATE_PORT", "Lookup the public-facing port that is NAT-ed to PRIVATE_PORT")
900
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
901 900
 	if err := cmd.Parse(args); err != nil {
902 901
 		return nil
903 902
 	}
904
-	if *help {
903
+	if cmd.NArg() != 2 {
905 904
 		cmd.Usage()
906 905
 		return nil
907 906
 	}
908
-	if cmd.BadArgs(2) {
909
-		os.Exit(1)
910
-	}
911 907
 
912 908
 	var (
913 909
 		port  = cmd.Arg(1)
... ...
@@ -951,18 +912,13 @@ func (cli *DockerCli) CmdRmi(args ...string) error {
951 951
 		force   = cmd.Bool([]string{"f", "-force"}, false, "Force removal of the image")
952 952
 		noprune = cmd.Bool([]string{"-no-prune"}, false, "Do not delete untagged parents")
953 953
 	)
954
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
955
-
956 954
 	if err := cmd.Parse(args); err != nil {
957 955
 		return nil
958 956
 	}
959
-	if *help {
957
+	if cmd.NArg() < 1 {
960 958
 		cmd.Usage()
961 959
 		return nil
962 960
 	}
963
-	if cmd.BadArgs(1) {
964
-		os.Exit(1)
965
-	}
966 961
 
967 962
 	v := url.Values{}
968 963
 	if *force {
... ...
@@ -1001,18 +957,14 @@ func (cli *DockerCli) CmdHistory(args ...string) error {
1001 1001
 	cmd := cli.Subcmd("history", "[OPTIONS] IMAGE", "Show the history of an image")
1002 1002
 	quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs")
1003 1003
 	noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
1004
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1005 1004
 
1006 1005
 	if err := cmd.Parse(args); err != nil {
1007 1006
 		return nil
1008 1007
 	}
1009
-	if *help {
1008
+	if cmd.NArg() != 1 {
1010 1009
 		cmd.Usage()
1011 1010
 		return nil
1012 1011
 	}
1013
-	if cmd.BadArgs(1) {
1014
-		os.Exit(1)
1015
-	}
1016 1012
 
1017 1013
 	body, _, err := readBody(cli.call("GET", "/images/"+cmd.Arg(0)+"/history", nil, false))
1018 1014
 	if err != nil {
... ...
@@ -1063,18 +1015,14 @@ func (cli *DockerCli) CmdRm(args ...string) error {
1063 1063
 	v := cmd.Bool([]string{"v", "-volumes"}, false, "Remove the volumes associated with the container")
1064 1064
 	link := cmd.Bool([]string{"l", "#link", "-link"}, false, "Remove the specified link and not the underlying container")
1065 1065
 	force := cmd.Bool([]string{"f", "-force"}, false, "Force the removal of a running container (uses SIGKILL)")
1066
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1067 1066
 
1068 1067
 	if err := cmd.Parse(args); err != nil {
1069 1068
 		return nil
1070 1069
 	}
1071
-	if *help {
1070
+	if cmd.NArg() < 1 {
1072 1071
 		cmd.Usage()
1073 1072
 		return nil
1074 1073
 	}
1075
-	if cmd.BadArgs(1) {
1076
-		os.Exit(1)
1077
-	}
1078 1074
 
1079 1075
 	val := url.Values{}
1080 1076
 	if *v {
... ...
@@ -1105,18 +1053,14 @@ func (cli *DockerCli) CmdRm(args ...string) error {
1105 1105
 func (cli *DockerCli) CmdKill(args ...string) error {
1106 1106
 	cmd := cli.Subcmd("kill", "[OPTIONS] CONTAINER [CONTAINER...]", "Kill a running container using SIGKILL or a specified signal")
1107 1107
 	signal := cmd.String([]string{"s", "-signal"}, "KILL", "Signal to send to the container")
1108
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1109 1108
 
1110 1109
 	if err := cmd.Parse(args); err != nil {
1111 1110
 		return nil
1112 1111
 	}
1113
-	if *help {
1112
+	if cmd.NArg() < 1 {
1114 1113
 		cmd.Usage()
1115 1114
 		return nil
1116 1115
 	}
1117
-	if cmd.BadArgs(1) {
1118
-		os.Exit(1)
1119
-	}
1120 1116
 
1121 1117
 	var encounteredError error
1122 1118
 	for _, name := range cmd.Args() {
... ...
@@ -1132,18 +1076,15 @@ func (cli *DockerCli) CmdKill(args ...string) error {
1132 1132
 
1133 1133
 func (cli *DockerCli) CmdImport(args ...string) error {
1134 1134
 	cmd := cli.Subcmd("import", "URL|- [REPOSITORY[:TAG]]", "Create an empty filesystem image and import the contents of the tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then optionally tag it.")
1135
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1136 1135
 
1137 1136
 	if err := cmd.Parse(args); err != nil {
1138 1137
 		return nil
1139 1138
 	}
1140
-	if *help {
1139
+	if cmd.NArg() < 1 {
1141 1140
 		cmd.Usage()
1142 1141
 		return nil
1143 1142
 	}
1144
-	if cmd.BadArgs(2) {
1145
-		os.Exit(1)
1146
-	}
1143
+
1147 1144
 	var (
1148 1145
 		v          = url.Values{}
1149 1146
 		src        = cmd.Arg(0)
... ...
@@ -1177,15 +1118,9 @@ func (cli *DockerCli) CmdImport(args ...string) error {
1177 1177
 
1178 1178
 func (cli *DockerCli) CmdPush(args ...string) error {
1179 1179
 	cmd := cli.Subcmd("push", "NAME[:TAG]", "Push an image or a repository to the registry")
1180
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1181
-
1182 1180
 	if err := cmd.Parse(args); err != nil {
1183 1181
 		return nil
1184 1182
 	}
1185
-	if *help {
1186
-		cmd.Usage()
1187
-		return nil
1188
-	}
1189 1183
 	name := cmd.Arg(0)
1190 1184
 
1191 1185
 	if name == "" {
... ...
@@ -1249,19 +1184,14 @@ func (cli *DockerCli) CmdPush(args ...string) error {
1249 1249
 func (cli *DockerCli) CmdPull(args ...string) error {
1250 1250
 	cmd := cli.Subcmd("pull", "NAME[:TAG]", "Pull an image or a repository from the registry")
1251 1251
 	tag := cmd.String([]string{"#t", "#-tag"}, "", "Download tagged image in a repository")
1252
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1253
-
1254 1252
 	if err := cmd.Parse(args); err != nil {
1255 1253
 		return nil
1256 1254
 	}
1257
-	if *help {
1255
+
1256
+	if cmd.NArg() != 1 {
1258 1257
 		cmd.Usage()
1259 1258
 		return nil
1260 1259
 	}
1261
-
1262
-	if cmd.BadArgs(1) {
1263
-		os.Exit(1)
1264
-	}
1265 1260
 	var (
1266 1261
 		v      = url.Values{}
1267 1262
 		remote = cmd.Arg(0)
... ...
@@ -1322,7 +1252,6 @@ func (cli *DockerCli) CmdImages(args ...string) error {
1322 1322
 	// FIXME: --viz and --tree are deprecated. Remove them in a future version.
1323 1323
 	flViz := cmd.Bool([]string{"#v", "#viz", "#-viz"}, false, "Output graph in graphviz format")
1324 1324
 	flTree := cmd.Bool([]string{"#t", "#tree", "#-tree"}, false, "Output graph in tree format")
1325
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1326 1325
 
1327 1326
 	flFilter := opts.NewListOpts(nil)
1328 1327
 	cmd.Var(&flFilter, []string{"f", "-filter"}, "Provide filter values (i.e. 'dangling=true')")
... ...
@@ -1330,13 +1259,10 @@ func (cli *DockerCli) CmdImages(args ...string) error {
1330 1330
 	if err := cmd.Parse(args); err != nil {
1331 1331
 		return nil
1332 1332
 	}
1333
-	if *help {
1333
+	if cmd.NArg() > 1 {
1334 1334
 		cmd.Usage()
1335 1335
 		return nil
1336 1336
 	}
1337
-	if cmd.BadArgs(1) {
1338
-		os.Exit(1)
1339
-	}
1340 1337
 
1341 1338
 	// Consolidate all filter flags, and sanity check them early.
1342 1339
 	// They'll get process in the daemon/server.
... ...
@@ -1559,7 +1485,6 @@ func (cli *DockerCli) CmdPs(args ...string) error {
1559 1559
 	since := cmd.String([]string{"#sinceId", "#-since-id", "-since"}, "", "Show only containers created since Id or Name, include non-running ones.")
1560 1560
 	before := cmd.String([]string{"#beforeId", "#-before-id", "-before"}, "", "Show only container created before Id or Name, include non-running ones.")
1561 1561
 	last := cmd.Int([]string{"n"}, -1, "Show n last created containers, include non-running ones.")
1562
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1563 1562
 
1564 1563
 	flFilter := opts.NewListOpts(nil)
1565 1564
 	cmd.Var(&flFilter, []string{"f", "-filter"}, "Provide filter values. Valid filters:\nexited=<int> - containers with exit code of <int>")
... ...
@@ -1567,10 +1492,6 @@ func (cli *DockerCli) CmdPs(args ...string) error {
1567 1567
 	if err := cmd.Parse(args); err != nil {
1568 1568
 		return nil
1569 1569
 	}
1570
-	if *help {
1571
-		cmd.Usage()
1572
-		return nil
1573
-	}
1574 1570
 	v := url.Values{}
1575 1571
 	if *last == -1 && *nLatest {
1576 1572
 		*last = 1
... ...
@@ -1683,14 +1604,9 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
1683 1683
 	flAuthor := cmd.String([]string{"a", "#author", "-author"}, "", "Author (e.g., \"John Hannibal Smith <hannibal@a-team.com>\")")
1684 1684
 	// FIXME: --run is deprecated, it will be replaced with inline Dockerfile commands.
1685 1685
 	flConfig := cmd.String([]string{"#run", "#-run"}, "", "This option is deprecated and will be removed in a future version in favor of inline Dockerfile-compatible commands")
1686
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1687 1686
 	if err := cmd.Parse(args); err != nil {
1688 1687
 		return nil
1689 1688
 	}
1690
-	if *help {
1691
-		cmd.Usage()
1692
-		return nil
1693
-	}
1694 1689
 
1695 1690
 	var (
1696 1691
 		name            = cmd.Arg(0)
... ...
@@ -1746,19 +1662,14 @@ func (cli *DockerCli) CmdEvents(args ...string) error {
1746 1746
 	cmd := cli.Subcmd("events", "[OPTIONS]", "Get real time events from the server")
1747 1747
 	since := cmd.String([]string{"#since", "-since"}, "", "Show all events created since timestamp")
1748 1748
 	until := cmd.String([]string{"-until"}, "", "Stream events until this timestamp")
1749
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1750
-
1751 1749
 	if err := cmd.Parse(args); err != nil {
1752 1750
 		return nil
1753 1751
 	}
1754
-	if *help {
1752
+
1753
+	if cmd.NArg() != 0 {
1755 1754
 		cmd.Usage()
1756 1755
 		return nil
1757 1756
 	}
1758
-	if cmd.BadArgs(0) {
1759
-		os.Exit(1)
1760
-	}
1761
-
1762 1757
 	var (
1763 1758
 		v   = url.Values{}
1764 1759
 		loc = time.FixedZone(time.Now().Zone())
... ...
@@ -1788,18 +1699,14 @@ func (cli *DockerCli) CmdEvents(args ...string) error {
1788 1788
 
1789 1789
 func (cli *DockerCli) CmdExport(args ...string) error {
1790 1790
 	cmd := cli.Subcmd("export", "CONTAINER", "Export the contents of a filesystem as a tar archive to STDOUT")
1791
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1792
-
1793 1791
 	if err := cmd.Parse(args); err != nil {
1794 1792
 		return nil
1795 1793
 	}
1796
-	if *help {
1794
+
1795
+	if cmd.NArg() != 1 {
1797 1796
 		cmd.Usage()
1798 1797
 		return nil
1799 1798
 	}
1800
-	if cmd.BadArgs(1) {
1801
-		os.Exit(1)
1802
-	}
1803 1799
 
1804 1800
 	if err := cli.stream("GET", "/containers/"+cmd.Arg(0)+"/export", nil, cli.out, nil); err != nil {
1805 1801
 		return err
... ...
@@ -1809,18 +1716,13 @@ func (cli *DockerCli) CmdExport(args ...string) error {
1809 1809
 
1810 1810
 func (cli *DockerCli) CmdDiff(args ...string) error {
1811 1811
 	cmd := cli.Subcmd("diff", "CONTAINER", "Inspect changes on a container's filesystem")
1812
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1813
-
1814 1812
 	if err := cmd.Parse(args); err != nil {
1815 1813
 		return nil
1816 1814
 	}
1817
-	if *help {
1815
+	if cmd.NArg() != 1 {
1818 1816
 		cmd.Usage()
1819 1817
 		return nil
1820 1818
 	}
1821
-	if cmd.BadArgs(1) {
1822
-		os.Exit(1)
1823
-	}
1824 1819
 
1825 1820
 	body, _, err := readBody(cli.call("GET", "/containers/"+cmd.Arg(0)+"/changes", nil, false))
1826 1821
 
... ...
@@ -1853,19 +1755,16 @@ func (cli *DockerCli) CmdLogs(args ...string) error {
1853 1853
 		follow = cmd.Bool([]string{"f", "-follow"}, false, "Follow log output")
1854 1854
 		times  = cmd.Bool([]string{"t", "-timestamps"}, false, "Show timestamps")
1855 1855
 		tail   = cmd.String([]string{"-tail"}, "all", "Output the specified number of lines at the end of logs (defaults to all logs)")
1856
-		help   = cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1857 1856
 	)
1858 1857
 
1859 1858
 	if err := cmd.Parse(args); err != nil {
1860 1859
 		return nil
1861 1860
 	}
1862
-	if *help {
1861
+
1862
+	if cmd.NArg() != 1 {
1863 1863
 		cmd.Usage()
1864 1864
 		return nil
1865 1865
 	}
1866
-	if cmd.BadArgs(1) {
1867
-		os.Exit(1)
1868
-	}
1869 1866
 	name := cmd.Arg(0)
1870 1867
 
1871 1868
 	steam, _, err := cli.call("GET", "/containers/"+name+"/json", nil, false)
... ...
@@ -1899,19 +1798,16 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
1899 1899
 		cmd     = cli.Subcmd("attach", "[OPTIONS] CONTAINER", "Attach to a running container")
1900 1900
 		noStdin = cmd.Bool([]string{"#nostdin", "-no-stdin"}, false, "Do not attach STDIN")
1901 1901
 		proxy   = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy all received signals to the process (even in non-TTY mode). SIGCHLD, SIGKILL, and SIGSTOP are not proxied.")
1902
-		help    = cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1903 1902
 	)
1904 1903
 
1905 1904
 	if err := cmd.Parse(args); err != nil {
1906 1905
 		return nil
1907 1906
 	}
1908
-	if *help {
1907
+
1908
+	if cmd.NArg() != 1 {
1909 1909
 		cmd.Usage()
1910 1910
 		return nil
1911 1911
 	}
1912
-	if cmd.BadArgs(1) {
1913
-		os.Exit(1)
1914
-	}
1915 1912
 	name := cmd.Arg(0)
1916 1913
 
1917 1914
 	stream, _, err := cli.call("GET", "/containers/"+name+"/json", nil, false)
... ...
@@ -1977,18 +1873,13 @@ func (cli *DockerCli) CmdSearch(args ...string) error {
1977 1977
 	trusted := cmd.Bool([]string{"#t", "#trusted", "#-trusted"}, false, "Only show trusted builds")
1978 1978
 	automated := cmd.Bool([]string{"-automated"}, false, "Only show automated builds")
1979 1979
 	stars := cmd.Int([]string{"s", "#stars", "-stars"}, 0, "Only displays with at least x stars")
1980
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
1981
-
1982 1980
 	if err := cmd.Parse(args); err != nil {
1983 1981
 		return nil
1984 1982
 	}
1985
-	if *help {
1983
+	if cmd.NArg() != 1 {
1986 1984
 		cmd.Usage()
1987 1985
 		return nil
1988 1986
 	}
1989
-	if cmd.BadArgs(1) {
1990
-		os.Exit(1)
1991
-	}
1992 1987
 
1993 1988
 	v := url.Values{}
1994 1989
 	v.Set("term", cmd.Arg(0))
... ...
@@ -2034,18 +1925,13 @@ type ports []int
2034 2034
 func (cli *DockerCli) CmdTag(args ...string) error {
2035 2035
 	cmd := cli.Subcmd("tag", "[OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]", "Tag an image into a repository")
2036 2036
 	force := cmd.Bool([]string{"f", "#force", "-force"}, false, "Force")
2037
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
2038
-
2039 2037
 	if err := cmd.Parse(args); err != nil {
2040 2038
 		return nil
2041 2039
 	}
2042
-	if *help {
2040
+	if cmd.NArg() != 2 {
2043 2041
 		cmd.Usage()
2044 2042
 		return nil
2045 2043
 	}
2046
-	if cmd.BadArgs(2) {
2047
-		os.Exit(1)
2048
-	}
2049 2044
 
2050 2045
 	var (
2051 2046
 		repository, tag = parsers.ParseRepositoryTag(cmd.Arg(1))
... ...
@@ -2110,11 +1996,6 @@ func (cli *DockerCli) CmdRun(args ...string) error {
2110 2110
 	if err != nil {
2111 2111
 		return err
2112 2112
 	}
2113
-	if config == nil {
2114
-		cmd.Usage()
2115
-		return nil
2116
-	}
2117
-
2118 2113
 	if config.Image == "" {
2119 2114
 		cmd.Usage()
2120 2115
 		return nil
... ...
@@ -2337,18 +2218,14 @@ func (cli *DockerCli) CmdRun(args ...string) error {
2337 2337
 
2338 2338
 func (cli *DockerCli) CmdCp(args ...string) error {
2339 2339
 	cmd := cli.Subcmd("cp", "CONTAINER:PATH HOSTPATH", "Copy files/folders from the PATH to the HOSTPATH")
2340
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
2341
-
2342 2340
 	if err := cmd.Parse(args); err != nil {
2343 2341
 		return nil
2344 2342
 	}
2345
-	if *help {
2343
+
2344
+	if cmd.NArg() != 2 {
2346 2345
 		cmd.Usage()
2347 2346
 		return nil
2348 2347
 	}
2349
-	if cmd.BadArgs(2) {
2350
-		os.Exit(1)
2351
-	}
2352 2348
 
2353 2349
 	var copyData engine.Env
2354 2350
 	info := strings.Split(cmd.Arg(0), ":")
... ...
@@ -2382,18 +2259,15 @@ func (cli *DockerCli) CmdCp(args ...string) error {
2382 2382
 func (cli *DockerCli) CmdSave(args ...string) error {
2383 2383
 	cmd := cli.Subcmd("save", "IMAGE", "Save an image to a tar archive (streamed to STDOUT by default)")
2384 2384
 	outfile := cmd.String([]string{"o", "-output"}, "", "Write to an file, instead of STDOUT")
2385
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
2386 2385
 
2387 2386
 	if err := cmd.Parse(args); err != nil {
2388 2387
 		return err
2389 2388
 	}
2390
-	if *help {
2389
+
2390
+	if cmd.NArg() != 1 {
2391 2391
 		cmd.Usage()
2392 2392
 		return nil
2393 2393
 	}
2394
-	if cmd.BadArgs(1) {
2395
-		os.Exit(1)
2396
-	}
2397 2394
 
2398 2395
 	var (
2399 2396
 		output io.Writer = cli.out
... ...
@@ -2415,18 +2289,15 @@ func (cli *DockerCli) CmdSave(args ...string) error {
2415 2415
 func (cli *DockerCli) CmdLoad(args ...string) error {
2416 2416
 	cmd := cli.Subcmd("load", "", "Load an image from a tar archive on STDIN")
2417 2417
 	infile := cmd.String([]string{"i", "-input"}, "", "Read from a tar archive file, instead of STDIN")
2418
-	help := cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
2419 2418
 
2420 2419
 	if err := cmd.Parse(args); err != nil {
2421 2420
 		return err
2422 2421
 	}
2423
-	if *help {
2422
+
2423
+	if cmd.NArg() != 0 {
2424 2424
 		cmd.Usage()
2425 2425
 		return nil
2426 2426
 	}
2427
-	if cmd.BadArgs(0) {
2428
-		os.Exit(1)
2429
-	}
2430 2427
 
2431 2428
 	var (
2432 2429
 		input io.Reader = cli.in
... ...
@@ -26,7 +26,6 @@ var (
26 26
 	flEnableCors  = flag.Bool([]string{"#api-enable-cors", "-api-enable-cors"}, false, "Enable CORS headers in the remote API")
27 27
 	flTls         = flag.Bool([]string{"-tls"}, false, "Use TLS; implied by tls-verify flags")
28 28
 	flTlsVerify   = flag.Bool([]string{"-tlsverify"}, false, "Use TLS and verify the remote (daemon: verify client, client: verify daemon)")
29
-	flHelp        = flag.Bool([]string{"h", "-help"}, false, "Print usage")
30 29
 
31 30
 	// these are initialized in init() below since their default values depend on dockerCertPath which isn't fully initialized until init() runs
32 31
 	flCa    *string
... ...
@@ -6,7 +6,6 @@ docker-attach - Attach to a running container
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker attach**
9
-[**--help**]/
10 9
 [**--no-stdin**[=*false*]]
11 10
 [**--sig-proxy**[=*true*]]
12 11
  CONTAINER
... ...
@@ -22,9 +21,6 @@ When you detach from a container the exit code will be returned to
22 22
 the client.
23 23
 
24 24
 # OPTIONS
25
-**--help**
26
-  Print usage statement
27
-
28 25
 **--no-stdin**=*true*|*false*
29 26
    Do not attach STDIN. The default is *false*.
30 27
 
... ...
@@ -6,7 +6,6 @@ docker-build - Build a new image from the source code at PATH
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker build**
9
-[**--help**]
10 9
 [**--force-rm**[=*false*]]
11 10
 [**--no-cache**[=*false*]]
12 11
 [**-q**|**--quiet**[=*false*]]
... ...
@@ -37,9 +36,6 @@ as context.
37 37
 **--no-cache**=*true*|*false*
38 38
    Do not use cache when building the image. The default is *false*.
39 39
 
40
-**--help**
41
-  Print usage statement
42
-
43 40
 **-q**, **--quiet**=*true*|*false*
44 41
    Suppress the verbose output generated by the containers. The default is *false*.
45 42
 
... ...
@@ -7,7 +7,6 @@ docker-commit - Create a new image from a container's changes
7 7
 # SYNOPSIS
8 8
 **docker commit**
9 9
 [**-a**|**--author**[=*AUTHOR*]]
10
-[**--help**]
11 10
 [**-m**|**--message**[=*MESSAGE*]]
12 11
 [**-p**|**--pause**[=*true*]]
13 12
  CONTAINER [REPOSITORY[:TAG]]
... ...
@@ -19,9 +18,6 @@ Using an existing container's name or ID you can create a new image.
19 19
 **-a**, **--author**=""
20 20
    Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
21 21
 
22
-**--help**
23
-  Print usage statement
24
-
25 22
 **-m**, **--message**=""
26 23
    Commit message
27 24
 
... ...
@@ -6,7 +6,6 @@ docker-cp - Copy files/folders from the PATH to the HOSTPATH
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker cp**
9
-[**--help**]
10 9
 CONTAINER:PATH HOSTPATH
11 10
 
12 11
 # DESCRIPTION
... ...
@@ -15,8 +14,7 @@ path. Paths are relative to the root of the filesystem. Files
15 15
 can be copied from a running or stopped container.
16 16
 
17 17
 # OPTIONS
18
-**--help**
19
-  Print usage statement
18
+There are no available options.
20 19
 
21 20
 # EXAMPLES
22 21
 An important shell script file, created in a bash shell, is copied from
... ...
@@ -6,7 +6,6 @@ docker-diff - Inspect changes on a container's filesystem
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker diff**
9
-[**--help**]
10 9
 CONTAINER
11 10
 
12 11
 # DESCRIPTION
... ...
@@ -15,8 +14,7 @@ shortened container ID or the container name set using
15 15
 **docker run --name** option.
16 16
 
17 17
 # OPTIONS
18
-**--help**
19
-  Print usage statement
18
+There are no available options.
20 19
 
21 20
 # EXAMPLES
22 21
 Inspect the changes to on a nginx container:
... ...
@@ -6,7 +6,6 @@ docker-events - Get real time events from the server
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker events**
9
-[**--help**]
10 9
 [**--since**[=*SINCE*]]
11 10
 [**--until**[=*UNTIL*]]
12 11
 
... ...
@@ -16,9 +15,6 @@ Get event information from the Docker daemon. Information can include historical
16 16
 information and real-time information.
17 17
 
18 18
 # OPTIONS
19
-**--help**
20
-  Print usage statement
21
-
22 19
 **--since**=""
23 20
    Show all events created since timestamp
24 21
 
... ...
@@ -6,7 +6,6 @@ docker-export - Export the contents of a filesystem as a tar archive to STDOUT
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker export**
9
-[**--help**]
10 9
 CONTAINER
11 10
 
12 11
 # DESCRIPTION
... ...
@@ -15,8 +14,7 @@ container ID or container name. The output is exported to STDOUT and can be
15 15
 redirected to a tar file.
16 16
 
17 17
 # OPTIONS
18
-**--help**
19
-  Print usage statement
18
+There are no available options.
20 19
 
21 20
 # EXAMPLES
22 21
 Export the contents of the container called angry_bell to a tar file
... ...
@@ -6,7 +6,6 @@ docker-history - Show the history of an image
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker history**
9
-[**--help**]
10 9
 [**--no-trunc**[=*false*]]
11 10
 [**-q**|**--quiet**[=*false*]]
12 11
  IMAGE
... ...
@@ -16,9 +15,6 @@ docker-history - Show the history of an image
16 16
 Show the history of when and how an image was created.
17 17
 
18 18
 # OPTIONS
19
-**--help**
20
-  Print usage statement
21
-
22 19
 **--no-trunc**=*true*|*false*
23 20
    Don't truncate output. The default is *false*.
24 21
 
... ...
@@ -6,7 +6,6 @@ docker-images - List images
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker images**
9
-[**--help**]
10 9
 [**-a**|**--all**[=*false*]]
11 10
 [**-f**|**--filter**[=*[]*]]
12 11
 [**--no-trunc**[=*false*]]
... ...
@@ -36,9 +35,6 @@ versions.
36 36
 **-f**, **--filter**=[]
37 37
    Provide filter values (i.e. 'dangling=true')
38 38
 
39
-**--help**
40
-  Print usage statement
41
-
42 39
 **--no-trunc**=*true*|*false*
43 40
    Don't truncate output. The default is *false*.
44 41
 
... ...
@@ -6,7 +6,6 @@ docker-import - Create an empty filesystem image and import the contents of the
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker import**
9
-[**--help**]
10 9
 URL|- [REPOSITORY[:TAG]]
11 10
 
12 11
 # DESCRIPTION
... ...
@@ -14,8 +13,7 @@ Create a new filesystem image from the contents of a tarball (`.tar`,
14 14
 `.tar.gz`, `.tgz`, `.bzip`, `.tar.xz`, `.txz`) into it, then optionally tag it.
15 15
 
16 16
 # OPTIONS
17
-**--help**
18
-  Print usage statement
17
+There are no available options.
19 18
 
20 19
 # EXAMPLES
21 20
 
... ...
@@ -6,7 +6,6 @@ docker-info - Display system-wide information
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker info**
9
-[**--help**]
10 9
 
11 10
 
12 11
 # DESCRIPTION
... ...
@@ -21,8 +20,7 @@ allocates a certain amount of data space and meta data space from the space
21 21
 available on the volume where `/var/lib/docker` is mounted.
22 22
 
23 23
 # OPTIONS
24
-**--help**
25
-  Print usage statement
24
+There are no available options.
26 25
 
27 26
 # EXAMPLES
28 27
 
... ...
@@ -6,7 +6,6 @@ docker-inspect - Return low-level information on a container or image
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker inspect**
9
-[**--help**]
10 9
 [**-f**|**--format**[=*FORMAT*]]
11 10
 CONTAINER|IMAGE [CONTAINER|IMAGE...]
12 11
 
... ...
@@ -18,9 +17,6 @@ array. If a format is specified, the given template will be executed for
18 18
 each result.
19 19
 
20 20
 # OPTIONS
21
-**--help**
22
-  Print usage statement
23
-
24 21
 **-f**, **--format**=""
25 22
    Format the output using the given go template.
26 23
 
... ...
@@ -6,7 +6,6 @@ docker-kill - Kill a running container using SIGKILL or a specified signal
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker kill**
9
-[**--help**]
10 9
 [**-s**|**--signal**[=*"KILL"*]]
11 10
  CONTAINER [CONTAINER...]
12 11
 
... ...
@@ -16,9 +15,6 @@ The main process inside each container specified will be sent SIGKILL,
16 16
  or any signal specified with option --signal.
17 17
 
18 18
 # OPTIONS
19
-**--help**
20
-  Print usage statement
21
-
22 19
 **-s**, **--signal**="KILL"
23 20
    Signal to send to the container
24 21
 
... ...
@@ -6,7 +6,6 @@ docker-load - Load an image from a tar archive on STDIN
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker load**
9
-[**--help**]
10 9
 [**-i**|**--input**[=*INPUT*]]
11 10
 
12 11
 
... ...
@@ -16,9 +15,6 @@ Loads a tarred repository from a file or the standard input stream.
16 16
 Restores both images and tags.
17 17
 
18 18
 # OPTIONS
19
-**--help**
20
-  Print usage statement
21
-
22 19
 **-i**, **--input**=""
23 20
    Read from a tar archive file, instead of STDIN
24 21
 
... ...
@@ -7,7 +7,6 @@ docker-login - Register or log in to a Docker registry server, if no server is s
7 7
 # SYNOPSIS
8 8
 **docker login**
9 9
 [**-e**|**--email**[=*EMAIL*]]
10
-[**--help**]
11 10
 [**-p**|**--password**[=*PASSWORD*]]
12 11
 [**-u**|**--username**[=*USERNAME*]]
13 12
  [SERVER]
... ...
@@ -21,9 +20,6 @@ login to a private registry you can specify this by adding the server name.
21 21
 **-e**, **--email**=""
22 22
    Email
23 23
 
24
-**--help**
25
-  Print usage statement
26
-
27 24
 **-p**, **--password**=""
28 25
    Password
29 26
 
... ...
@@ -7,7 +7,6 @@ docker-logs - Fetch the logs of a container
7 7
 # SYNOPSIS
8 8
 **docker logs**
9 9
 [**-f**|**--follow**[=*false*]]
10
-[**--help**]
11 10
 [**-t**|**--timestamps**[=*false*]]
12 11
 [**--tail**[=*"all"*]]
13 12
 CONTAINER
... ...
@@ -23,9 +22,6 @@ The **docker logs --follow** command combines commands **docker logs** and
23 23
 then continue streaming new output from the container’s stdout and stderr.
24 24
 
25 25
 # OPTIONS
26
-**--help**
27
-  Print usage statement
28
-
29 26
 **-f**, **--follow**=*true*|*false*
30 27
    Follow log output. The default is *false*.
31 28
 
... ...
@@ -6,7 +6,6 @@ docker-port - Lookup the public-facing port that is NAT-ed to PRIVATE_PORT
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker port**
9
-[**--help**]
10 9
 CONTAINER PRIVATE_PORT
11 10
 
12 11
 # OPTIONS
... ...
@@ -8,7 +8,6 @@ docker-ps - List containers
8 8
 **docker ps**
9 9
 [**-a**|**--all**[=*false*]]
10 10
 [**--before**[=*BEFORE*]]
11
-[**--help**]
12 11
 [**-f**|**--filter**[=*[]*]]
13 12
 [**-l**|**--latest**[=*false*]]
14 13
 [**-n**[=*-1*]]
... ...
@@ -30,9 +29,6 @@ the running containers.
30 30
 **--before**=""
31 31
    Show only container created before Id or Name, include non-running ones.
32 32
 
33
-**--help**
34
-  Print usage statement
35
-
36 33
 **-f**, **--filter**=[]
37 34
    Provide filter values. Valid filters:
38 35
                           exited=<int> - containers with exit code of <int>
... ...
@@ -6,7 +6,6 @@ docker-pull - Pull an image or a repository from the registry
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker pull**
9
-[**--help**] 
10 9
 NAME[:TAG]
11 10
 
12 11
 # DESCRIPTION
... ...
@@ -17,10 +16,9 @@ images for that repository name are pulled down including any tags.
17 17
 It is also possible to specify a non-default registry to pull from.
18 18
 
19 19
 # OPTIONS
20
-**--help**
21
-  Print usage statement
20
+There are no available options.
22 21
 
23
-# EXAMPLE
22
+# EXAMPLES
24 23
 
25 24
 # Pull a repository with multiple images
26 25
 
... ...
@@ -6,7 +6,6 @@ docker-push - Push an image or a repository to the registry
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker push**
9
-[**--help**]
10 9
 NAME[:TAG]
11 10
 
12 11
 # DESCRIPTION
... ...
@@ -16,8 +15,7 @@ image can be pushed to another, perhaps private, registry as demonstrated in
16 16
 the example below.
17 17
 
18 18
 # OPTIONS
19
-**--help**
20
-  Print usage statement
19
+There are no available options.
21 20
 
22 21
 # EXAMPLES
23 22
 
... ...
@@ -6,7 +6,6 @@ docker-restart - Restart a running container
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker restart**
9
-[**--help**]
10 9
 [**-t**|**--time**[=*10*]]
11 10
  CONTAINER [CONTAINER...]
12 11
 
... ...
@@ -14,9 +13,6 @@ docker-restart - Restart a running container
14 14
 Restart each container listed.
15 15
 
16 16
 # OPTIONS
17
-**--help**
18
-  Print usage statement
19
-
20 17
 **-t**, **--time**=10
21 18
    Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default is 10 seconds.
22 19
 
... ...
@@ -19,9 +19,6 @@ remove a running container unless you use the \fB-f\fR option. To see all
19 19
 containers on a host use the **docker ps -a** command.
20 20
 
21 21
 # OPTIONS
22
-**--help**
23
-  Print usage statement
24
-
25 22
 **-f**, **--force**=*true*|*false*
26 23
    Force the removal of a running container (uses SIGKILL). The default is *false*.
27 24
 
... ...
@@ -7,7 +7,6 @@ docker-rmi - Remove one or more images
7 7
 # SYNOPSIS
8 8
 **docker rmi**
9 9
 [**-f**|**--force**[=*false*]]
10
-[**--help**]
11 10
 [**--no-prune**[=*false*]]
12 11
 IMAGE [IMAGE...]
13 12
 
... ...
@@ -22,9 +21,6 @@ use the **docker images** command.
22 22
 **-f**, **--force**=*true*|*false*
23 23
    Force removal of the image. The default is *false*.
24 24
 
25
-**--help**
26
-  Print usage statement
27
-
28 25
 **--no-prune**=*true*|*false*
29 26
    Do not delete untagged parents. The default is *false*.
30 27
 
... ...
@@ -21,7 +21,6 @@ docker-run - Run a command in a new container
21 21
 [**--env-file**[=*[]*]]
22 22
 [**--expose**[=*[]*]]
23 23
 [**-h**|**--hostname**[=*HOSTNAME*]]
24
-[**--help**]
25 24
 [**-i**|**--interactive**[=*false*]]
26 25
 [**--link**[=*[]*]]
27 26
 [**--lxc-conf**[=*[]*]]
... ...
@@ -133,9 +132,6 @@ developer can expose the port using the EXPOSE parameter of the Dockerfile, 2)
133 133
 the operator can use the **--expose** option with **docker run**, or 3) the
134 134
 container can be started with the **--link**.
135 135
 
136
-**--help**
137
-  Print usage statement
138
-
139 136
 **-h**, **--hostname**=*hostname*
140 137
    Sets the container host name that is available inside the container.
141 138
 
... ...
@@ -6,7 +6,6 @@ docker-save - Save an image to a tar archive (streamed to STDOUT by default)
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker save**
9
-[**--help**]
10 9
 [**-o**|**--output**[=*OUTPUT*]]
11 10
 IMAGE
12 11
 
... ...
@@ -17,9 +16,6 @@ parent layers, and all tags + versions, or specified repo:tag.
17 17
 Stream to a file instead of STDOUT by using **-o**.
18 18
 
19 19
 # OPTIONS
20
-**--help**
21
-  Print usage statement
22
-
23 20
 **-o**, **--output**=""
24 21
    Write to an file, instead of STDOUT
25 22
 
... ...
@@ -7,7 +7,6 @@ docker-search - Search the Docker Hub for images
7 7
 # SYNOPSIS
8 8
 **docker search**
9 9
 [**--automated**[=*false*]]
10
-[**--help**]
11 10
 [**--no-trunc**[=*false*]]
12 11
 [**-s**|**--stars**[=*0*]]
13 12
 TERM
... ...
@@ -23,9 +22,6 @@ is automated.
23 23
 **--automated**=*true*|*false*
24 24
    Only show automated builds. The default is *false*.
25 25
 
26
-**--help**
27
-  Print usage statement
28
-
29 26
 **--no-trunc**=*true*|*false*
30 27
    Don't truncate output. The default is *false*.
31 28
 
... ...
@@ -7,7 +7,6 @@ docker-start - Restart a stopped container
7 7
 # SYNOPSIS
8 8
 **docker start**
9 9
 [**-a**|**--attach**[=*false*]]
10
-[**--help**]
11 10
 [**-i**|**--interactive**[=*false*]]
12 11
 CONTAINER [CONTAINER...]
13 12
 
... ...
@@ -19,9 +18,6 @@ Start a stopped container.
19 19
 **-a**, **--attach**=*true*|*false*
20 20
    Attach container's STDOUT and STDERR and forward all signals to the process. The default is *false*.
21 21
 
22
-**--help**
23
-  Print usage statement
24
-
25 22
 **-i**, **--interactive**=*true*|*false*
26 23
    Attach container's STDIN. The default is *false*.
27 24
 
... ...
@@ -6,7 +6,6 @@ docker-stop - Stop a running container by sending SIGTERM and then SIGKILL after
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker stop**
9
-[**--help**]
10 9
 [**-t**|**--time**[=*10*]]
11 10
  CONTAINER [CONTAINER...]
12 11
 
... ...
@@ -15,9 +14,6 @@ Stop a running container (Send SIGTERM, and then SIGKILL after
15 15
  grace period)
16 16
 
17 17
 # OPTIONS
18
-**--help**
19
-  Print usage statement
20
-
21 18
 **-t**, **--time**=10
22 19
    Number of seconds to wait for the container to stop before killing it. Default is 10 seconds.
23 20
 
... ...
@@ -7,7 +7,6 @@ docker-tag - Tag an image into a repository
7 7
 # SYNOPSIS
8 8
 **docker tag**
9 9
 [**-f**|**--force**[=*false*]]
10
-[**--help**]
11 10
  IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
12 11
 
13 12
 # DESCRIPTION
... ...
@@ -6,7 +6,6 @@ docker-top - Display the running processes of a container
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker top**
9
-[**--help**]
10 9
 CONTAINER [ps OPTIONS]
11 10
 
12 11
 # DESCRIPTION
... ...
@@ -15,8 +14,7 @@ Look up the running process of the container. ps-OPTION can be any of the
15 15
  options you would pass to a Linux ps command.
16 16
 
17 17
 # OPTIONS
18
-**--help**
19
-  Print usage statement
18
+There are no available options.
20 19
 
21 20
 # EXAMPLES
22 21
 
... ...
@@ -6,7 +6,6 @@ docker-wait - Block until a container stops, then print its exit code.
6 6
 
7 7
 # SYNOPSIS
8 8
 **docker wait**
9
-[**--help**]
10 9
 CONTAINER [CONTAINER...]
11 10
 
12 11
 # DESCRIPTION
... ...
@@ -14,8 +13,7 @@ CONTAINER [CONTAINER...]
14 14
 Block until a container stops, then print its exit code.
15 15
 
16 16
 # OPTIONS
17
-**--help**
18
-  Print usage statement
17
+There are no available options.
19 18
 
20 19
 # EXAMPLES
21 20
 
... ...
@@ -26,9 +26,6 @@ To see the man page for a command run **man docker <command>**.
26 26
 **-D**=*true*|*false*
27 27
    Enable debug mode. Default is false.
28 28
 
29
-**--help**
30
-  Print usage statement
31
-
32 29
 **-H**, **--host**=[unix:///var/run/docker.sock]: tcp://[host:port] to bind or
33 30
 unix://[/path/to/socket] to use.
34 31
    The socket(s) to bind to in daemon mode specified using one or more
... ...
@@ -15,19 +15,6 @@ or execute `docker help`:
15 15
 
16 16
       ...
17 17
 
18
-## Help
19
-To list the help on any command just execute the command, followed by the `--help` option.
20
-
21
-    $ sudo docker run --help
22
-
23
-    Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
24
-
25
-    Run a command in a new container
26
-
27
-      -a, --attach=[]            Attach to STDIN, STDOUT or STDERR.
28
-      -c, --cpu-shares=0         CPU shares (relative weight)
29
-    ...
30
-
31 18
 ## Option types
32 19
 
33 20
 Single character commandline options can be combined, so rather than
... ...
@@ -395,19 +395,6 @@ func Lookup(name string) *Flag {
395 395
 	return CommandLine.formal[name]
396 396
 }
397 397
 
398
-func (f *FlagSet) BadArgs(nargs int) bool {
399
-	if NArg() < nargs {
400
-		fmt.Fprintf(f.out(), "docker: '%s' requires arguments. See 'docker %s --help'.\n", f.name, f.name)
401
-		return true
402
-	} else {
403
-		if nargs == 0 && NArg() != 0 {
404
-			fmt.Fprintf(f.out(), "docker: '%s' does not require arguments. See 'docker %s --help'.\n", f.name, f.name)
405
-			return true
406
-		}
407
-	}
408
-	return false
409
-}
410
-
411 398
 // Set sets the value of the named flag.
412 399
 func (f *FlagSet) Set(name, value string) error {
413 400
 	flag, ok := f.formal[name]
... ...
@@ -481,7 +468,7 @@ func defaultUsage(f *FlagSet) {
481 481
 // Usage prints to standard error a usage message documenting all defined command-line flags.
482 482
 // The function is a variable that may be changed to point to a custom function.
483 483
 var Usage = func() {
484
-	fmt.Fprintf(CommandLine.output, "Usage of %s:\n", os.Args[0])
484
+	fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
485 485
 	PrintDefaults()
486 486
 }
487 487
 
... ...
@@ -770,7 +757,7 @@ func Var(value Value, names []string, usage string) {
770 770
 func (f *FlagSet) failf(format string, a ...interface{}) error {
771 771
 	err := fmt.Errorf(format, a...)
772 772
 	fmt.Fprintln(f.out(), err)
773
-	fmt.Fprintf(f.out(), "See 'docker %s --help'.\n", f.name)
773
+	f.usage()
774 774
 	return err
775 775
 }
776 776
 
... ...
@@ -3,7 +3,6 @@ package runconfig
3 3
 import (
4 4
 	"fmt"
5 5
 	"io/ioutil"
6
-	"os"
7 6
 	"path"
8 7
 	"strconv"
9 8
 	"strings"
... ...
@@ -76,8 +75,6 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
76 76
 		flNetMode         = cmd.String([]string{"-net"}, "bridge", "Set the Network mode for the container\n'bridge': creates a new network stack for the container on the docker bridge\n'none': no networking for this container\n'container:<name|id>': reuses another container network stack\n'host': use the host network stack inside the container.  Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure.")
77 77
 		flRestartPolicy   = cmd.String([]string{"-restart"}, "", "Restart policy to apply when a container exits (no, on-failure[:max-retry], always)")
78 78
 		// For documentation purpose
79
-		help = cmd.Bool([]string{"#help", "-help"}, false, "Print usage")
80
-
81 79
 		_ = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy received signals to the process (even in non-TTY mode). SIGCHLD, SIGSTOP, and SIGKILL are not proxied.")
82 80
 		_ = cmd.String([]string{"#name", "-name"}, "", "Assign a name to the container")
83 81
 	)
... ...
@@ -169,14 +166,9 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
169 169
 		entrypoint []string
170 170
 		image      string
171 171
 	)
172
-
173
-	if *help {
174
-		return nil, nil, cmd, nil
175
-	}
176
-	if cmd.BadArgs(1) {
177
-		os.Exit(1)
172
+	if len(parsedArgs) >= 1 {
173
+		image = cmd.Arg(0)
178 174
 	}
179
-	image = cmd.Arg(0)
180 175
 	if len(parsedArgs) > 1 {
181 176
 		runCmd = parsedArgs[1:]
182 177
 	}