Browse code

Use consistent command description

Signed-off-by: Lei Jitang <leijitang@huawei.com>

Lei Jitang authored on 2015/10/08 21:46:21
Showing 44 changed files
... ...
@@ -17,7 +17,7 @@ import (
17 17
 //
18 18
 // Usage: docker attach [OPTIONS] CONTAINER
19 19
 func (cli *DockerCli) CmdAttach(args ...string) error {
20
-	cmd := Cli.Subcmd("attach", []string{"CONTAINER"}, "Attach to a running container", true)
20
+	cmd := Cli.Subcmd("attach", []string{"CONTAINER"}, Cli.DockerCommands["attach"].Description, true)
21 21
 	noStdin := cmd.Bool([]string{"#nostdin", "-no-stdin"}, false, "Do not attach STDIN")
22 22
 	proxy := cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy all received signals to the process")
23 23
 
... ...
@@ -49,7 +49,7 @@ const (
49 49
 //
50 50
 // Usage: docker build [OPTIONS] PATH | URL | -
51 51
 func (cli *DockerCli) CmdBuild(args ...string) error {
52
-	cmd := Cli.Subcmd("build", []string{"PATH | URL | -"}, "Build a new image from the source code at PATH", true)
52
+	cmd := Cli.Subcmd("build", []string{"PATH | URL | -"}, Cli.DockerCommands["build"].Description, true)
53 53
 	tag := cmd.String([]string{"t", "-tag"}, "", "Repository name (and optionally a tag) for the image")
54 54
 	suppressOutput := cmd.Bool([]string{"q", "-quiet"}, false, "Suppress the verbose output generated by the containers")
55 55
 	noCache := cmd.Bool([]string{"#no-cache", "-no-cache"}, false, "Do not use cache when building the image")
... ...
@@ -18,7 +18,7 @@ import (
18 18
 //
19 19
 // Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
20 20
 func (cli *DockerCli) CmdCommit(args ...string) error {
21
-	cmd := Cli.Subcmd("commit", []string{"CONTAINER [REPOSITORY[:TAG]]"}, "Create a new image from a container's changes", true)
21
+	cmd := Cli.Subcmd("commit", []string{"CONTAINER [REPOSITORY[:TAG]]"}, Cli.DockerCommands["commit"].Description, true)
22 22
 	flPause := cmd.Bool([]string{"p", "-pause"}, true, "Pause container during commit")
23 23
 	flComment := cmd.String([]string{"m", "-message"}, "", "Commit message")
24 24
 	flAuthor := cmd.String([]string{"a", "#author", "-author"}, "", "Author (e.g., \"John Hannibal Smith <hannibal@a-team.com>\")")
... ...
@@ -43,8 +43,8 @@ func (cli *DockerCli) CmdCp(args ...string) error {
43 43
 		"cp",
44 44
 		[]string{"CONTAINER:PATH LOCALPATH|-", "LOCALPATH|- CONTAINER:PATH"},
45 45
 		strings.Join([]string{
46
-			"Copy files/folders between a container and your host.\n",
47
-			"Use '-' as the source to read a tar archive from stdin\n",
46
+			Cli.DockerCommands["cp"].Description,
47
+			"\nUse '-' as the source to read a tar archive from stdin\n",
48 48
 			"and extract it to a directory destination in a container.\n",
49 49
 			"Use '-' as the destination to stream a tar archive of a\n",
50 50
 			"container source to stdout.",
... ...
@@ -159,7 +159,7 @@ func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runc
159 159
 //
160 160
 // Usage: docker create [OPTIONS] IMAGE [COMMAND] [ARG...]
161 161
 func (cli *DockerCli) CmdCreate(args ...string) error {
162
-	cmd := Cli.Subcmd("create", []string{"IMAGE [COMMAND] [ARG...]"}, "Create a new container", true)
162
+	cmd := Cli.Subcmd("create", []string{"IMAGE [COMMAND] [ARG...]"}, Cli.DockerCommands["create"].Description, true)
163 163
 	addTrustedFlags(cmd, true)
164 164
 
165 165
 	// These are flags not stored in Config/HostConfig
... ...
@@ -18,7 +18,7 @@ import (
18 18
 //
19 19
 // Usage: docker diff CONTAINER
20 20
 func (cli *DockerCli) CmdDiff(args ...string) error {
21
-	cmd := Cli.Subcmd("diff", []string{"CONTAINER"}, "Inspect changes on a container's filesystem", true)
21
+	cmd := Cli.Subcmd("diff", []string{"CONTAINER"}, Cli.DockerCommands["diff"].Description, true)
22 22
 	cmd.Require(flag.Exact, 1)
23 23
 
24 24
 	cmd.ParseFlags(args, true)
... ...
@@ -15,7 +15,7 @@ import (
15 15
 //
16 16
 // Usage: docker events [OPTIONS]
17 17
 func (cli *DockerCli) CmdEvents(args ...string) error {
18
-	cmd := Cli.Subcmd("events", nil, "Get real time events from the server", true)
18
+	cmd := Cli.Subcmd("events", nil, Cli.DockerCommands["events"].Description, true)
19 19
 	since := cmd.String([]string{"#since", "-since"}, "", "Show all events created since timestamp")
20 20
 	until := cmd.String([]string{"-until"}, "", "Stream events until this timestamp")
21 21
 	flFilter := opts.NewListOpts(nil)
... ...
@@ -16,7 +16,7 @@ import (
16 16
 //
17 17
 // Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
18 18
 func (cli *DockerCli) CmdExec(args ...string) error {
19
-	cmd := Cli.Subcmd("exec", []string{"CONTAINER COMMAND [ARG...]"}, "Run a command in a running container", true)
19
+	cmd := Cli.Subcmd("exec", []string{"CONTAINER COMMAND [ARG...]"}, Cli.DockerCommands["exec"].Description, true)
20 20
 
21 21
 	execConfig, err := runconfig.ParseExec(cmd, args)
22 22
 	// just in case the ParseExec does not exit
... ...
@@ -14,7 +14,7 @@ import (
14 14
 //
15 15
 // Usage: docker export [OPTIONS] CONTAINER
16 16
 func (cli *DockerCli) CmdExport(args ...string) error {
17
-	cmd := Cli.Subcmd("export", []string{"CONTAINER"}, "Export the contents of a container's filesystem as a tar archive", true)
17
+	cmd := Cli.Subcmd("export", []string{"CONTAINER"}, Cli.DockerCommands["export"].Description, true)
18 18
 	outfile := cmd.String([]string{"o", "-output"}, "", "Write to a file, instead of STDOUT")
19 19
 	cmd.Require(flag.Exact, 1)
20 20
 
... ...
@@ -19,7 +19,7 @@ import (
19 19
 //
20 20
 // Usage: docker history [OPTIONS] IMAGE
21 21
 func (cli *DockerCli) CmdHistory(args ...string) error {
22
-	cmd := Cli.Subcmd("history", []string{"IMAGE"}, "Show the history of an image", true)
22
+	cmd := Cli.Subcmd("history", []string{"IMAGE"}, Cli.DockerCommands["history"].Description, true)
23 23
 	human := cmd.Bool([]string{"H", "-human"}, true, "Print sizes and dates in human readable format")
24 24
 	quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs")
25 25
 	noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
... ...
@@ -22,7 +22,7 @@ import (
22 22
 //
23 23
 // Usage: docker images [OPTIONS] [REPOSITORY]
24 24
 func (cli *DockerCli) CmdImages(args ...string) error {
25
-	cmd := Cli.Subcmd("images", []string{"[REPOSITORY[:TAG]]"}, "List images", true)
25
+	cmd := Cli.Subcmd("images", []string{"[REPOSITORY[:TAG]]"}, Cli.DockerCommands["images"].Description, true)
26 26
 	quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs")
27 27
 	all := cmd.Bool([]string{"a", "-all"}, false, "Show all images (default hides intermediate images)")
28 28
 	noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
... ...
@@ -20,7 +20,7 @@ import (
20 20
 //
21 21
 // Usage: docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
22 22
 func (cli *DockerCli) CmdImport(args ...string) error {
23
-	cmd := Cli.Subcmd("import", []string{"file|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)
23
+	cmd := Cli.Subcmd("import", []string{"file|URL|- [REPOSITORY[:TAG]]"}, Cli.DockerCommands["import"].Description, true)
24 24
 	flChanges := opts.NewListOpts(nil)
25 25
 	cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image")
26 26
 	message := cmd.String([]string{"m", "-message"}, "", "Set commit message for imported image")
... ...
@@ -16,7 +16,7 @@ import (
16 16
 //
17 17
 // Usage: docker info
18 18
 func (cli *DockerCli) CmdInfo(args ...string) error {
19
-	cmd := Cli.Subcmd("info", nil, "Display system-wide information", true)
19
+	cmd := Cli.Subcmd("info", nil, Cli.DockerCommands["info"].Description, true)
20 20
 	cmd.Require(flag.Exact, 0)
21 21
 
22 22
 	cmd.ParseFlags(args, true)
... ...
@@ -24,7 +24,7 @@ var funcMap = template.FuncMap{
24 24
 //
25 25
 // Usage: docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]
26 26
 func (cli *DockerCli) CmdInspect(args ...string) error {
27
-	cmd := Cli.Subcmd("inspect", []string{"CONTAINER|IMAGE [CONTAINER|IMAGE...]"}, "Return low-level information on a container or image", true)
27
+	cmd := Cli.Subcmd("inspect", []string{"CONTAINER|IMAGE [CONTAINER|IMAGE...]"}, Cli.DockerCommands["inspect"].Description, true)
28 28
 	tmplStr := cmd.String([]string{"f", "#format", "-format"}, "", "Format the output using the given go template")
29 29
 	inspectType := cmd.String([]string{"-type"}, "", "Return JSON for specified type, (e.g image or container)")
30 30
 	cmd.Require(flag.Min, 1)
... ...
@@ -11,7 +11,7 @@ import (
11 11
 //
12 12
 // Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...]
13 13
 func (cli *DockerCli) CmdKill(args ...string) error {
14
-	cmd := Cli.Subcmd("kill", []string{"CONTAINER [CONTAINER...]"}, "Kill a running container using SIGKILL or a specified signal", true)
14
+	cmd := Cli.Subcmd("kill", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["kill"].Description, true)
15 15
 	signal := cmd.String([]string{"s", "-signal"}, "KILL", "Signal to send to the container")
16 16
 	cmd.Require(flag.Min, 1)
17 17
 
... ...
@@ -14,7 +14,7 @@ import (
14 14
 //
15 15
 // Usage: docker load [OPTIONS]
16 16
 func (cli *DockerCli) CmdLoad(args ...string) error {
17
-	cmd := Cli.Subcmd("load", nil, "Load an image from a tar archive or STDIN", true)
17
+	cmd := Cli.Subcmd("load", nil, Cli.DockerCommands["load"].Description, true)
18 18
 	infile := cmd.String([]string{"i", "-input"}, "", "Read from a tar archive file, instead of STDIN")
19 19
 	cmd.Require(flag.Exact, 0)
20 20
 
... ...
@@ -22,7 +22,7 @@ import (
22 22
 //
23 23
 // Usage: docker login SERVER
24 24
 func (cli *DockerCli) CmdLogin(args ...string) error {
25
-	cmd := Cli.Subcmd("login", []string{"[SERVER]"}, "Register or log in to a Docker registry server, if no server is\nspecified \""+registry.IndexServer+"\" is the default.", true)
25
+	cmd := Cli.Subcmd("login", []string{"[SERVER]"}, Cli.DockerCommands["login"].Description+".\nIf no server is specified \""+registry.IndexServer+"\" is the default.", true)
26 26
 	cmd.Require(flag.Max, 1)
27 27
 
28 28
 	var username, password, email string
... ...
@@ -14,7 +14,7 @@ import (
14 14
 //
15 15
 // Usage: docker logout [SERVER]
16 16
 func (cli *DockerCli) CmdLogout(args ...string) error {
17
-	cmd := Cli.Subcmd("logout", []string{"[SERVER]"}, "Log out from a Docker registry, if no server is\nspecified \""+registry.IndexServer+"\" is the default.", true)
17
+	cmd := Cli.Subcmd("logout", []string{"[SERVER]"}, Cli.DockerCommands["logout"].Description+".\nIf no server is specified \""+registry.IndexServer+"\" is the default.", true)
18 18
 	cmd.Require(flag.Max, 1)
19 19
 
20 20
 	cmd.ParseFlags(args, true)
... ...
@@ -15,7 +15,7 @@ import (
15 15
 //
16 16
 // docker logs [OPTIONS] CONTAINER
17 17
 func (cli *DockerCli) CmdLogs(args ...string) error {
18
-	cmd := Cli.Subcmd("logs", []string{"CONTAINER"}, "Fetch the logs of a container", true)
18
+	cmd := Cli.Subcmd("logs", []string{"CONTAINER"}, Cli.DockerCommands["logs"].Description, true)
19 19
 	follow := cmd.Bool([]string{"f", "-follow"}, false, "Follow log output")
20 20
 	since := cmd.String([]string{"-since"}, "", "Show logs since timestamp")
21 21
 	times := cmd.Bool([]string{"t", "-timestamps"}, false, "Show timestamps")
... ...
@@ -11,7 +11,7 @@ import (
11 11
 //
12 12
 // Usage: docker pause CONTAINER [CONTAINER...]
13 13
 func (cli *DockerCli) CmdPause(args ...string) error {
14
-	cmd := Cli.Subcmd("pause", []string{"CONTAINER [CONTAINER...]"}, "Pause all processes within a container", true)
14
+	cmd := Cli.Subcmd("pause", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["pause"].Description, true)
15 15
 	cmd.Require(flag.Min, 1)
16 16
 
17 17
 	cmd.ParseFlags(args, true)
... ...
@@ -15,7 +15,7 @@ import (
15 15
 //
16 16
 // Usage: docker port CONTAINER [PRIVATE_PORT[/PROTO]]
17 17
 func (cli *DockerCli) CmdPort(args ...string) error {
18
-	cmd := Cli.Subcmd("port", []string{"CONTAINER [PRIVATE_PORT[/PROTO]]"}, "List port mappings for the CONTAINER, or lookup the public-facing port that\nis NAT-ed to the PRIVATE_PORT", true)
18
+	cmd := Cli.Subcmd("port", []string{"CONTAINER [PRIVATE_PORT[/PROTO]]"}, Cli.DockerCommands["port"].Description, true)
19 19
 	cmd.Require(flag.Min, 1)
20 20
 
21 21
 	cmd.ParseFlags(args, true)
... ...
@@ -23,7 +23,7 @@ func (cli *DockerCli) CmdPs(args ...string) error {
23 23
 		psFilterArgs = filters.Args{}
24 24
 		v            = url.Values{}
25 25
 
26
-		cmd      = Cli.Subcmd("ps", nil, "List containers", true)
26
+		cmd      = Cli.Subcmd("ps", nil, Cli.DockerCommands["ps"].Description, true)
27 27
 		quiet    = cmd.Bool([]string{"q", "-quiet"}, false, "Only display numeric IDs")
28 28
 		size     = cmd.Bool([]string{"s", "-size"}, false, "Display total file sizes")
29 29
 		all      = cmd.Bool([]string{"a", "-all"}, false, "Show all containers (default shows just running)")
... ...
@@ -15,7 +15,7 @@ import (
15 15
 //
16 16
 // Usage: docker pull [OPTIONS] IMAGENAME[:TAG|@DIGEST]
17 17
 func (cli *DockerCli) CmdPull(args ...string) error {
18
-	cmd := Cli.Subcmd("pull", []string{"NAME[:TAG|@DIGEST]"}, "Pull an image or a repository from a registry", true)
18
+	cmd := Cli.Subcmd("pull", []string{"NAME[:TAG|@DIGEST]"}, Cli.DockerCommands["pull"].Description, true)
19 19
 	allTags := cmd.Bool([]string{"a", "-all-tags"}, false, "Download all tagged images in the repository")
20 20
 	addTrustedFlags(cmd, true)
21 21
 	cmd.Require(flag.Exact, 1)
... ...
@@ -14,7 +14,7 @@ import (
14 14
 //
15 15
 // Usage: docker push NAME[:TAG]
16 16
 func (cli *DockerCli) CmdPush(args ...string) error {
17
-	cmd := Cli.Subcmd("push", []string{"NAME[:TAG]"}, "Push an image or a repository to a registry", true)
17
+	cmd := Cli.Subcmd("push", []string{"NAME[:TAG]"}, Cli.DockerCommands["push"].Description, true)
18 18
 	addTrustedFlags(cmd, false)
19 19
 	cmd.Require(flag.Exact, 1)
20 20
 
... ...
@@ -12,7 +12,7 @@ import (
12 12
 //
13 13
 // Usage: docker rename OLD_NAME NEW_NAME
14 14
 func (cli *DockerCli) CmdRename(args ...string) error {
15
-	cmd := Cli.Subcmd("rename", []string{"OLD_NAME NEW_NAME"}, "Rename a container", true)
15
+	cmd := Cli.Subcmd("rename", []string{"OLD_NAME NEW_NAME"}, Cli.DockerCommands["rename"].Description, true)
16 16
 	cmd.Require(flag.Exact, 2)
17 17
 
18 18
 	cmd.ParseFlags(args, true)
... ...
@@ -13,7 +13,7 @@ import (
13 13
 //
14 14
 // Usage: docker restart [OPTIONS] CONTAINER [CONTAINER...]
15 15
 func (cli *DockerCli) CmdRestart(args ...string) error {
16
-	cmd := Cli.Subcmd("restart", []string{"CONTAINER [CONTAINER...]"}, "Restart a container", true)
16
+	cmd := Cli.Subcmd("restart", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["restart"].Description, true)
17 17
 	nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing the container")
18 18
 	cmd.Require(flag.Min, 1)
19 19
 
... ...
@@ -13,7 +13,7 @@ import (
13 13
 //
14 14
 // Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
15 15
 func (cli *DockerCli) CmdRm(args ...string) error {
16
-	cmd := Cli.Subcmd("rm", []string{"CONTAINER [CONTAINER...]"}, "Remove one or more containers", true)
16
+	cmd := Cli.Subcmd("rm", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["rm"].Description, true)
17 17
 	v := cmd.Bool([]string{"v", "-volumes"}, false, "Remove the volumes associated with the container")
18 18
 	link := cmd.Bool([]string{"l", "#link", "-link"}, false, "Remove the specified link")
19 19
 	force := cmd.Bool([]string{"f", "-force"}, false, "Force the removal of a running container (uses SIGKILL)")
... ...
@@ -14,7 +14,7 @@ import (
14 14
 //
15 15
 // Usage: docker rmi [OPTIONS] IMAGE [IMAGE...]
16 16
 func (cli *DockerCli) CmdRmi(args ...string) error {
17
-	cmd := Cli.Subcmd("rmi", []string{"IMAGE [IMAGE...]"}, "Remove one or more images", true)
17
+	cmd := Cli.Subcmd("rmi", []string{"IMAGE [IMAGE...]"}, Cli.DockerCommands["rmi"].Description, true)
18 18
 	force := cmd.Bool([]string{"f", "-force"}, false, "Force removal of the image")
19 19
 	noprune := cmd.Bool([]string{"-no-prune"}, false, "Do not delete untagged parents")
20 20
 	cmd.Require(flag.Min, 1)
... ...
@@ -40,7 +40,7 @@ func (cid *cidFile) Write(id string) error {
40 40
 //
41 41
 // Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
42 42
 func (cli *DockerCli) CmdRun(args ...string) error {
43
-	cmd := Cli.Subcmd("run", []string{"IMAGE [COMMAND] [ARG...]"}, "Run a command in a new container", true)
43
+	cmd := Cli.Subcmd("run", []string{"IMAGE [COMMAND] [ARG...]"}, Cli.DockerCommands["run"].Description, true)
44 44
 	addTrustedFlags(cmd, true)
45 45
 
46 46
 	// These are flags not stored in Config/HostConfig
... ...
@@ -15,7 +15,7 @@ import (
15 15
 //
16 16
 // Usage: docker save [OPTIONS] IMAGE [IMAGE...]
17 17
 func (cli *DockerCli) CmdSave(args ...string) error {
18
-	cmd := Cli.Subcmd("save", []string{"IMAGE [IMAGE...]"}, "Save an image(s) to a tar archive (streamed to STDOUT by default)", true)
18
+	cmd := Cli.Subcmd("save", []string{"IMAGE [IMAGE...]"}, Cli.DockerCommands["save"].Description+" (streamed to STDOUT by default)", true)
19 19
 	outfile := cmd.String([]string{"o", "-output"}, "", "Write to a file, instead of STDOUT")
20 20
 	cmd.Require(flag.Min, 1)
21 21
 
... ...
@@ -26,7 +26,7 @@ func (r ByStars) Less(i, j int) bool { return r[i].StarCount < r[j].StarCount }
26 26
 //
27 27
 // Usage: docker search [OPTIONS] TERM
28 28
 func (cli *DockerCli) CmdSearch(args ...string) error {
29
-	cmd := Cli.Subcmd("search", []string{"TERM"}, "Search the Docker Hub for images", true)
29
+	cmd := Cli.Subcmd("search", []string{"TERM"}, Cli.DockerCommands["search"].Description, true)
30 30
 	noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
31 31
 	trusted := cmd.Bool([]string{"#t", "#trusted", "#-trusted"}, false, "Only show trusted builds")
32 32
 	automated := cmd.Bool([]string{"-automated"}, false, "Only show automated builds")
... ...
@@ -45,7 +45,7 @@ func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal {
45 45
 //
46 46
 // Usage: docker start [OPTIONS] CONTAINER [CONTAINER...]
47 47
 func (cli *DockerCli) CmdStart(args ...string) error {
48
-	cmd := Cli.Subcmd("start", []string{"CONTAINER [CONTAINER...]"}, "Start one or more containers", true)
48
+	cmd := Cli.Subcmd("start", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["start"].Description, true)
49 49
 	attach := cmd.Bool([]string{"a", "-attach"}, false, "Attach STDOUT/STDERR and forward signals")
50 50
 	openStdin := cmd.Bool([]string{"i", "-interactive"}, false, "Attach container's STDIN")
51 51
 	cmd.Require(flag.Min, 1)
... ...
@@ -141,7 +141,7 @@ func (s *containerStats) Display(w io.Writer) error {
141 141
 //
142 142
 // Usage: docker stats CONTAINER [CONTAINER...]
143 143
 func (cli *DockerCli) CmdStats(args ...string) error {
144
-	cmd := Cli.Subcmd("stats", []string{"CONTAINER [CONTAINER...]"}, "Display a live stream of one or more containers' resource usage statistics", true)
144
+	cmd := Cli.Subcmd("stats", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["stats"].Description, true)
145 145
 	noStream := cmd.Bool([]string{"-no-stream"}, false, "Disable streaming stats and only pull the first result")
146 146
 	cmd.Require(flag.Min, 1)
147 147
 
... ...
@@ -15,7 +15,7 @@ import (
15 15
 //
16 16
 // Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
17 17
 func (cli *DockerCli) CmdStop(args ...string) error {
18
-	cmd := Cli.Subcmd("stop", []string{"CONTAINER [CONTAINER...]"}, "Stop a container by sending SIGTERM and then SIGKILL after a\ngrace period", true)
18
+	cmd := Cli.Subcmd("stop", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["stop"].Description+".\nSending SIGTERM and then SIGKILL after a grace period", true)
19 19
 	nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing it")
20 20
 	cmd.Require(flag.Min, 1)
21 21
 
... ...
@@ -13,7 +13,7 @@ import (
13 13
 //
14 14
 // Usage: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
15 15
 func (cli *DockerCli) CmdTag(args ...string) error {
16
-	cmd := Cli.Subcmd("tag", []string{"IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]"}, "Tag an image into a repository", true)
16
+	cmd := Cli.Subcmd("tag", []string{"IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]"}, Cli.DockerCommands["tag"].Description, true)
17 17
 	force := cmd.Bool([]string{"f", "#force", "-force"}, false, "Force")
18 18
 	cmd.Require(flag.Exact, 2)
19 19
 
... ...
@@ -16,7 +16,7 @@ import (
16 16
 //
17 17
 // Usage: docker top CONTAINER
18 18
 func (cli *DockerCli) CmdTop(args ...string) error {
19
-	cmd := Cli.Subcmd("top", []string{"CONTAINER [ps OPTIONS]"}, "Display the running processes of a container", true)
19
+	cmd := Cli.Subcmd("top", []string{"CONTAINER [ps OPTIONS]"}, Cli.DockerCommands["top"].Description, true)
20 20
 	cmd.Require(flag.Min, 1)
21 21
 
22 22
 	cmd.ParseFlags(args, true)
... ...
@@ -11,7 +11,7 @@ import (
11 11
 //
12 12
 // Usage: docker unpause CONTAINER [CONTAINER...]
13 13
 func (cli *DockerCli) CmdUnpause(args ...string) error {
14
-	cmd := Cli.Subcmd("unpause", []string{"CONTAINER [CONTAINER...]"}, "Unpause all processes within a container", true)
14
+	cmd := Cli.Subcmd("unpause", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["unpause"].Description, true)
15 15
 	cmd.Require(flag.Min, 1)
16 16
 
17 17
 	cmd.ParseFlags(args, true)
... ...
@@ -43,7 +43,7 @@ type versionData struct {
43 43
 //
44 44
 // Usage: docker version
45 45
 func (cli *DockerCli) CmdVersion(args ...string) (err error) {
46
-	cmd := Cli.Subcmd("version", nil, "Show the Docker version information.", true)
46
+	cmd := Cli.Subcmd("version", nil, Cli.DockerCommands["version"].Description, true)
47 47
 	tmplStr := cmd.String([]string{"f", "#format", "-format"}, "", "Format the output using the given go template")
48 48
 	cmd.Require(flag.Exact, 0)
49 49
 
... ...
@@ -20,7 +20,7 @@ import (
20 20
 //
21 21
 // Usage: docker volume <COMMAND> <OPTS>
22 22
 func (cli *DockerCli) CmdVolume(args ...string) error {
23
-	description := "Manage Docker volumes\n\nCommands:\n"
23
+	description := Cli.DockerCommands["volume"].Description + "\n\nCommands:\n"
24 24
 	commands := [][]string{
25 25
 		{"create", "Create a volume"},
26 26
 		{"inspect", "Return low-level information on a volume"},
... ...
@@ -13,7 +13,7 @@ import (
13 13
 //
14 14
 // Usage: docker wait CONTAINER [CONTAINER...]
15 15
 func (cli *DockerCli) CmdWait(args ...string) error {
16
-	cmd := Cli.Subcmd("wait", []string{"CONTAINER [CONTAINER...]"}, "Block until a container stops, then print its exit code.", true)
16
+	cmd := Cli.Subcmd("wait", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["wait"].Description, true)
17 17
 	cmd.Require(flag.Min, 1)
18 18
 
19 19
 	cmd.ParseFlags(args, true)
... ...
@@ -18,3 +18,61 @@ type CommonFlags struct {
18 18
 	TLSOptions *tlsconfig.Options
19 19
 	TrustKey   string
20 20
 }
21
+
22
+// Command is the struct contains command name and description
23
+type Command struct {
24
+	Name        string
25
+	Description string
26
+}
27
+
28
+var dockerCommands = []Command{
29
+	{"attach", "Attach to a running container"},
30
+	{"build", "Build an image from a Dockerfile"},
31
+	{"commit", "Create a new image from a container's changes"},
32
+	{"cp", "Copy files/folders between a container and the local filesystem"},
33
+	{"create", "Create a new container"},
34
+	{"diff", "Inspect changes on a container's filesystem"},
35
+	{"events", "Get real time events from the server"},
36
+	{"exec", "Run a command in a running container"},
37
+	{"export", "Export a container's filesystem as a tar archive"},
38
+	{"history", "Show the history of an image"},
39
+	{"images", "List images"},
40
+	{"import", "Import the contents from a tarball to create a filesystem image"},
41
+	{"info", "Display system-wide information"},
42
+	{"inspect", "Return low-level information on a container or image"},
43
+	{"kill", "Kill a running container"},
44
+	{"load", "Load an image from a tar archive or STDIN"},
45
+	{"login", "Register or log in to a Docker registry"},
46
+	{"logout", "Log out from a Docker registry"},
47
+	{"logs", "Fetch the logs of a container"},
48
+	{"pause", "Pause all processes within a container"},
49
+	{"port", "List port mappings or a specific mapping for the CONTAINER"},
50
+	{"ps", "List containers"},
51
+	{"pull", "Pull an image or a repository from a registry"},
52
+	{"push", "Push an image or a repository to a registry"},
53
+	{"rename", "Rename a container"},
54
+	{"restart", "Restart a container"},
55
+	{"rm", "Remove one or more containers"},
56
+	{"rmi", "Remove one or more images"},
57
+	{"run", "Run a command in a new container"},
58
+	{"save", "Save an image(s) to a tar archive"},
59
+	{"search", "Search the Docker Hub for images"},
60
+	{"start", "Start one or more stopped containers"},
61
+	{"stats", "Display a live stream of container(s) resource usage statistics"},
62
+	{"stop", "Stop a running container"},
63
+	{"tag", "Tag an image into a repository"},
64
+	{"top", "Display the running processes of a container"},
65
+	{"unpause", "Unpause all processes within a container"},
66
+	{"version", "Show the Docker version information"},
67
+	{"volume", "Manage Docker volumes"},
68
+	{"wait", "Block until a container stops, then print its exit code"},
69
+}
70
+
71
+// DockerCommands stores all the docker command
72
+var DockerCommands = make(map[string]Command)
73
+
74
+func init() {
75
+	for _, cmd := range dockerCommands {
76
+		DockerCommands[cmd.Name] = cmd
77
+	}
78
+}
... ...
@@ -36,7 +36,7 @@ func main() {
36 36
 		help := "\nCommands:\n"
37 37
 
38 38
 		for _, cmd := range dockerCommands {
39
-			help += fmt.Sprintf("    %-10.10s%s\n", cmd.name, cmd.description)
39
+			help += fmt.Sprintf("    %-10.10s%s\n", cmd.Name, cmd.Description)
40 40
 		}
41 41
 
42 42
 		help += "\nRun 'docker COMMAND --help' for more information on a command."
... ...
@@ -1,64 +1,30 @@
1 1
 package main
2 2
 
3
-import flag "github.com/docker/docker/pkg/mflag"
3
+import (
4
+	"sort"
5
+
6
+	"github.com/docker/docker/cli"
7
+	flag "github.com/docker/docker/pkg/mflag"
8
+)
4 9
 
5 10
 var (
6 11
 	flHelp    = flag.Bool([]string{"h", "-help"}, false, "Print usage")
7 12
 	flVersion = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
8 13
 )
9 14
 
10
-type command struct {
11
-	name        string
12
-	description string
13
-}
14
-
15
-type byName []command
15
+type byName []cli.Command
16 16
 
17 17
 func (a byName) Len() int           { return len(a) }
18 18
 func (a byName) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
19
-func (a byName) Less(i, j int) bool { return a[i].name < a[j].name }
19
+func (a byName) Less(i, j int) bool { return a[i].Name < a[j].Name }
20
+
21
+var dockerCommands []cli.Command
20 22
 
21 23
 // TODO(tiborvass): do not show 'daemon' on client-only binaries
22
-// and deduplicate description in dockerCommands and cli subcommands
23
-var dockerCommands = []command{
24
-	{"attach", "Attach to a running container"},
25
-	{"build", "Build an image from a Dockerfile"},
26
-	{"commit", "Create a new image from a container's changes"},
27
-	{"cp", "Copy files/folders between a container and the local filesystem"},
28
-	{"create", "Create a new container"},
29
-	{"diff", "Inspect changes on a container's filesystem"},
30
-	{"events", "Get real time events from the server"},
31
-	{"exec", "Run a command in a running container"},
32
-	{"export", "Export a container's filesystem as a tar archive"},
33
-	{"history", "Show the history of an image"},
34
-	{"images", "List images"},
35
-	{"import", "Import the contents from a tarball to create a filesystem image"},
36
-	{"info", "Display system-wide information"},
37
-	{"inspect", "Return low-level information on a container or image"},
38
-	{"kill", "Kill a running container"},
39
-	{"load", "Load an image from a tar archive or STDIN"},
40
-	{"login", "Register or log in to a Docker registry"},
41
-	{"logout", "Log out from a Docker registry"},
42
-	{"logs", "Fetch the logs of a container"},
43
-	{"pause", "Pause all processes within a container"},
44
-	{"port", "List port mappings or a specific mapping for the CONTAINER"},
45
-	{"ps", "List containers"},
46
-	{"pull", "Pull an image or a repository from a registry"},
47
-	{"push", "Push an image or a repository to a registry"},
48
-	{"rename", "Rename a container"},
49
-	{"restart", "Restart a container"},
50
-	{"rm", "Remove one or more containers"},
51
-	{"rmi", "Remove one or more images"},
52
-	{"run", "Run a command in a new container"},
53
-	{"save", "Save an image(s) to a tar archive"},
54
-	{"search", "Search the Docker Hub for images"},
55
-	{"start", "Start one or more containers"},
56
-	{"stats", "Display a live stream of container(s) resource usage statistics"},
57
-	{"stop", "Stop a container"},
58
-	{"tag", "Tag an image into a repository"},
59
-	{"top", "Display the running processes of a container"},
60
-	{"unpause", "Unpause all processes within a container"},
61
-	{"version", "Show the Docker version information"},
62
-	{"volume", "Manage Docker volumes"},
63
-	{"wait", "Block until a container stops, then print its exit code"},
24
+
25
+func init() {
26
+	for _, cmd := range cli.DockerCommands {
27
+		dockerCommands = append(dockerCommands, cmd)
28
+	}
29
+	sort.Sort(byName(dockerCommands))
64 30
 }
... ...
@@ -2,10 +2,14 @@
2 2
 
3 3
 package main
4 4
 
5
-import "sort"
5
+import (
6
+	"sort"
7
+
8
+	"github.com/docker/docker/cli"
9
+)
6 10
 
7 11
 func init() {
8
-	dockerCommands = append(dockerCommands, command{"network", "Network management"})
12
+	dockerCommands = append(dockerCommands, cli.Command{Name: "network", Description: "Network management"})
9 13
 
10 14
 	//Sorting logic required here to pass Command Sort Test.
11 15
 	sort.Sort(byName(dockerCommands))