Browse code

Fix 'docker ps --help' so the options don't span more than one line and add a testcase to catch this in the future.

While in there I also:
- removed extra periods from the few options that had them (new test)
- made the --filter option consistent across all command

Signed-off-by: Doug Davis <dug@us.ibm.com>

Doug Davis authored on 2015/03/04 02:04:06
Showing 4 changed files
... ...
@@ -609,7 +609,7 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
609 609
 
610 610
 func (cli *DockerCli) CmdStop(args ...string) error {
611 611
 	cmd := cli.Subcmd("stop", "CONTAINER [CONTAINER...]", "Stop a running container by sending SIGTERM and then SIGKILL after a\ngrace period", true)
612
-	nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing it.")
612
+	nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing it")
613 613
 	cmd.Require(flag.Min, 1)
614 614
 
615 615
 	utils.ParseFlags(cmd, args, true)
... ...
@@ -632,7 +632,7 @@ func (cli *DockerCli) CmdStop(args ...string) error {
632 632
 
633 633
 func (cli *DockerCli) CmdRestart(args ...string) error {
634 634
 	cmd := cli.Subcmd("restart", "CONTAINER [CONTAINER...]", "Restart a running container", true)
635
-	nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing the container.")
635
+	nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing the container")
636 636
 	cmd.Require(flag.Min, 1)
637 637
 
638 638
 	utils.ParseFlags(cmd, args, true)
... ...
@@ -847,7 +847,7 @@ func (cli *DockerCli) CmdRename(args ...string) error {
847 847
 
848 848
 func (cli *DockerCli) CmdInspect(args ...string) error {
849 849
 	cmd := cli.Subcmd("inspect", "CONTAINER|IMAGE [CONTAINER|IMAGE...]", "Return low-level information on a container or image", true)
850
-	tmplStr := cmd.String([]string{"f", "#format", "-format"}, "", "Format the output using the given go template.")
850
+	tmplStr := cmd.String([]string{"f", "#format", "-format"}, "", "Format the output using the given go template")
851 851
 	cmd.Require(flag.Min, 1)
852 852
 
853 853
 	utils.ParseFlags(cmd, args, true)
... ...
@@ -1161,7 +1161,7 @@ func (cli *DockerCli) CmdKill(args ...string) error {
1161 1161
 func (cli *DockerCli) CmdImport(args ...string) error {
1162 1162
 	cmd := cli.Subcmd("import", "URL|- [REPOSITORY[:TAG]]", "Create an empty filesystem image and import the contents of the\ntarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then\noptionally tag it.", true)
1163 1163
 	flChanges := opts.NewListOpts(nil)
1164
-	cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image.")
1164
+	cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image")
1165 1165
 	cmd.Require(flag.Min, 1)
1166 1166
 
1167 1167
 	utils.ParseFlags(cmd, args, true)
... ...
@@ -1333,7 +1333,7 @@ func (cli *DockerCli) CmdImages(args ...string) error {
1333 1333
 	flTree := cmd.Bool([]string{"#t", "#tree", "#-tree"}, false, "Output graph in tree format")
1334 1334
 
1335 1335
 	flFilter := opts.NewListOpts(nil)
1336
-	cmd.Var(&flFilter, []string{"f", "-filter"}, "Provide filter values (i.e., 'dangling=true')")
1336
+	cmd.Var(&flFilter, []string{"f", "-filter"}, "Filter output based on conditions provided")
1337 1337
 	cmd.Require(flag.Max, 1)
1338 1338
 
1339 1339
 	utils.ParseFlags(cmd, args, true)
... ...
@@ -1561,15 +1561,15 @@ func (cli *DockerCli) CmdPs(args ...string) error {
1561 1561
 		size     = cmd.Bool([]string{"s", "-size"}, false, "Display total file sizes")
1562 1562
 		all      = cmd.Bool([]string{"a", "-all"}, false, "Show all containers (default shows just running)")
1563 1563
 		noTrunc  = cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
1564
-		nLatest  = cmd.Bool([]string{"l", "-latest"}, false, "Show the latest created container, include non-running.")
1565
-		since    = cmd.String([]string{"#sinceId", "#-since-id", "-since"}, "", "Show created since Id or Name, include non-running.")
1566
-		before   = cmd.String([]string{"#beforeId", "#-before-id", "-before"}, "", "Show only container created before Id or Name.")
1567
-		last     = cmd.Int([]string{"n"}, -1, "Show n last created containers, include non-running.")
1564
+		nLatest  = cmd.Bool([]string{"l", "-latest"}, false, "Show the latest created container, include non-running")
1565
+		since    = cmd.String([]string{"#sinceId", "#-since-id", "-since"}, "", "Show created since Id or Name, include non-running")
1566
+		before   = cmd.String([]string{"#beforeId", "#-before-id", "-before"}, "", "Show only container created before Id or Name")
1567
+		last     = cmd.Int([]string{"n"}, -1, "Show n last created containers, include non-running")
1568 1568
 		flFilter = opts.NewListOpts(nil)
1569 1569
 	)
1570 1570
 	cmd.Require(flag.Exact, 0)
1571 1571
 
1572
-	cmd.Var(&flFilter, []string{"f", "-filter"}, "Provide filter values. Valid filters:\nexited=<int> - containers with exit code of <int>\nstatus=(restarting|running|paused|exited)")
1572
+	cmd.Var(&flFilter, []string{"f", "-filter"}, "Filter output based on conditions provided")
1573 1573
 
1574 1574
 	utils.ParseFlags(cmd, args, true)
1575 1575
 	if *last == -1 && *nLatest {
... ...
@@ -1711,7 +1711,7 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
1711 1711
 	flComment := cmd.String([]string{"m", "-message"}, "", "Commit message")
1712 1712
 	flAuthor := cmd.String([]string{"a", "#author", "-author"}, "", "Author (e.g., \"John Hannibal Smith <hannibal@a-team.com>\")")
1713 1713
 	flChanges := opts.NewListOpts(nil)
1714
-	cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image.")
1714
+	cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image")
1715 1715
 	// FIXME: --run is deprecated, it will be replaced with inline Dockerfile commands.
1716 1716
 	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")
1717 1717
 	cmd.Require(flag.Max, 2)
... ...
@@ -1771,7 +1771,7 @@ func (cli *DockerCli) CmdEvents(args ...string) error {
1771 1771
 	since := cmd.String([]string{"#since", "-since"}, "", "Show all events created since timestamp")
1772 1772
 	until := cmd.String([]string{"-until"}, "", "Stream events until this timestamp")
1773 1773
 	flFilter := opts.NewListOpts(nil)
1774
-	cmd.Var(&flFilter, []string{"f", "-filter"}, "Provide filter values (i.e., 'event=stop')")
1774
+	cmd.Var(&flFilter, []string{"f", "-filter"}, "Filter output based on conditions provided")
1775 1775
 	cmd.Require(flag.Exact, 0)
1776 1776
 
1777 1777
 	utils.ParseFlags(cmd, args, true)
... ...
@@ -26,7 +26,7 @@ To list the help on any command just execute the command, followed by the `--hel
26 26
 
27 27
     Run a command in a new container
28 28
 
29
-      -a, --attach=[]            Attach to STDIN, STDOUT or STDERR.
29
+      -a, --attach=[]            Attach to STDIN, STDOUT or STDERR
30 30
       -c, --cpu-shares=0         CPU shares (relative weight)
31 31
     ...
32 32
 
... ...
@@ -756,7 +756,7 @@ Creates a new container.
756 756
 
757 757
     Create a new container
758 758
 
759
-      -a, --attach=[]            Attach to STDIN, STDOUT or STDERR.
759
+      -a, --attach=[]            Attach to STDIN, STDOUT or STDERR
760 760
       --add-host=[]              Add a custom host-to-IP mapping (host:ip)
761 761
       -c, --cpu-shares=0         CPU shares (relative weight)
762 762
       --cap-add=[]               Add Linux capabilities
... ...
@@ -875,7 +875,7 @@ For example:
875 875
 
876 876
     Get real time events from the server
877 877
 
878
-      -f, --filter=[]    Provide filter values (i.e., 'event=stop')
878
+      -f, --filter=[]    Filter output based on conditions provided
879 879
       --since=""         Show all events created since timestamp
880 880
       --until=""         Stream events until this timestamp
881 881
 
... ...
@@ -1060,7 +1060,7 @@ To see how the `docker:latest` image was built:
1060 1060
     List images
1061 1061
 
1062 1062
       -a, --all=false      Show all images (default hides intermediate images)
1063
-      -f, --filter=[]      Provide filter values (i.e., 'dangling=true')
1063
+      -f, --filter=[]      Filter output based on conditions provided
1064 1064
       --no-trunc=false     Don't truncate output
1065 1065
       -q, --quiet=false    Only show numeric IDs
1066 1066
 
... ...
@@ -1241,7 +1241,7 @@ ensure we know how your setup is configured.
1241 1241
 
1242 1242
     Return low-level information on a container or image
1243 1243
 
1244
-      -f, --format=""    Format the output using the given go template.
1244
+      -f, --format=""    Format the output using the given go template
1245 1245
 
1246 1246
 By default, this will render all results in a JSON array. If a format is
1247 1247
 specified, the given template will be executed for each result.
... ...
@@ -1439,16 +1439,14 @@ The `docker rename` command allows the container to be renamed to a different na
1439 1439
     List containers
1440 1440
 
1441 1441
       -a, --all=false       Show all containers (default shows just running)
1442
-      --before=""           Show only container created before Id or Name.
1443
-      -f, --filter=[]       Provide filter values. Valid filters:
1444
-                              exited=<int> - containers with exit code of <int>
1445
-                              status=(restarting|running|paused|exited)
1446
-      -l, --latest=false    Show the latest created container, include non-running.
1447
-      -n=-1                 Show n last created containers, include non-running .
1442
+      --before=""           Show only container created before Id or Name
1443
+      -f, --filter=[]       Filter output based on conditions provided
1444
+      -l, --latest=false    Show the latest created container, include non-running
1445
+      -n=-1                 Show n last created containers, include non-running 
1448 1446
       --no-trunc=false      Don't truncate output
1449 1447
       -q, --quiet=false     Only display numeric IDs
1450 1448
       -s, --size=false      Display total file sizes
1451
-      --since=""            Show created since Id or Name, include non-running.
1449
+      --since=""            Show created since Id or Name, include non-running
1452 1450
 
1453 1451
 Running `docker ps --no-trunc` showing 2 linked containers.
1454 1452
 
... ...
@@ -1531,7 +1529,7 @@ registry or to a self-hosted one.
1531 1531
 
1532 1532
     Restart a running container
1533 1533
 
1534
-      -t, --time=10      Seconds to wait for stop before killing the container.
1534
+      -t, --time=10      Seconds to wait for stop before killing the container
1535 1535
 
1536 1536
 ## rm
1537 1537
 
... ...
@@ -1611,7 +1609,7 @@ removed before the image is removed.
1611 1611
 
1612 1612
     Run a command in a new container
1613 1613
 
1614
-      -a, --attach=[]            Attach to STDIN, STDOUT or STDERR.
1614
+      -a, --attach=[]            Attach to STDIN, STDOUT or STDERR
1615 1615
       --add-host=[]              Add a custom host-to-IP mapping (host:ip)
1616 1616
       -c, --cpu-shares=0         CPU shares (relative weight)
1617 1617
       --cap-add=[]               Add Linux capabilities
... ...
@@ -2066,7 +2064,7 @@ containers. Stopped containers will not return any data.
2066 2066
     Stop a running container by sending SIGTERM and then SIGKILL after a
2067 2067
 	grace period
2068 2068
 
2069
-      -t, --time=10      Seconds to wait for stop before killing it.
2069
+      -t, --time=10      Seconds to wait for stop before killing it
2070 2070
 
2071 2071
 The main process inside the container will receive `SIGTERM`, and after a
2072 2072
 grace period, `SIGKILL`.
... ...
@@ -11,7 +11,7 @@ import (
11 11
 	"github.com/docker/docker/pkg/homedir"
12 12
 )
13 13
 
14
-func TestHelpWidth(t *testing.T) {
14
+func TestHelpTextVerify(t *testing.T) {
15 15
 	// Make sure main help text fits within 80 chars and that
16 16
 	// on non-windows system we use ~ when possible (to shorten things).
17 17
 	// Test for HOME set to its default value and set to "/" on linux
... ...
@@ -58,6 +58,7 @@ func TestHelpWidth(t *testing.T) {
58 58
 			if len(line) > 80 {
59 59
 				t.Fatalf("Line is too long(%d chars):\n%s", len(line), line)
60 60
 			}
61
+
61 62
 			if scanForHome && strings.Contains(line, `=`+home) {
62 63
 				t.Fatalf("Line should use '%q' instead of %q:\n%s", homedir.GetShortcutString(), home, line)
63 64
 			}
... ...
@@ -108,6 +109,7 @@ func TestHelpWidth(t *testing.T) {
108 108
 					t.Fatalf("Help for %q is too long(%d chars):\n%s", cmd,
109 109
 						len(line), line)
110 110
 				}
111
+
111 112
 				if scanForHome && strings.Contains(line, `"`+home) {
112 113
 					t.Fatalf("Help for %q should use ~ instead of %q on:\n%s",
113 114
 						cmd, home, line)
... ...
@@ -116,6 +118,18 @@ func TestHelpWidth(t *testing.T) {
116 116
 				if i >= 0 && i != len(line)-1 && line[i+1] != '/' {
117 117
 					t.Fatalf("Help for %q should not have used ~:\n%s", cmd, line)
118 118
 				}
119
+
120
+				// If a line starts with 4 spaces then assume someone
121
+				// added a multi-line description for an option and we need
122
+				// to flag it
123
+				if strings.HasPrefix(line, "    ") {
124
+					t.Fatalf("Help for %q should not have a multi-line option: %s", cmd, line)
125
+				}
126
+
127
+				// Options should NOT end with a period
128
+				if strings.HasPrefix(line, "  -") && strings.HasSuffix(line, ".") {
129
+					t.Fatalf("Help for %q should not end with a period: %s", cmd, line)
130
+				}
119 131
 			}
120 132
 		}
121 133
 
... ...
@@ -126,5 +140,5 @@ func TestHelpWidth(t *testing.T) {
126 126
 		}
127 127
 	}
128 128
 
129
-	logDone("help - widths")
129
+	logDone("help - verify text")
130 130
 }
... ...
@@ -66,7 +66,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
66 66
 		flReadonlyRootfs  = cmd.Bool([]string{"-read-only"}, false, "Mount the container's root filesystem as read only")
67 67
 	)
68 68
 
69
-	cmd.Var(&flAttach, []string{"a", "-attach"}, "Attach to STDIN, STDOUT or STDERR.")
69
+	cmd.Var(&flAttach, []string{"a", "-attach"}, "Attach to STDIN, STDOUT or STDERR")
70 70
 	cmd.Var(&flVolumes, []string{"v", "-volume"}, "Bind mount a volume")
71 71
 	cmd.Var(&flLinks, []string{"#link", "-link"}, "Add link to another container")
72 72
 	cmd.Var(&flDevices, []string{"-device"}, "Add a host device to the container")