From 4cb0c93f9287d29934894c871d156801122516cd Mon Sep 17 00:00:00 2001 From: Josh Hawn Date: Wed, 13 May 2015 19:45:01 -0700 Subject: [PATCH] api/client: Allow for multi-line usage help Subcommands can provide multiple usage synopses. Docker-DCO-1.1-Signed-off-by: Josh Hawn (github: jlhawn) --- api/client/attach.go | 2 +- api/client/build.go | 2 +- api/client/cli.go | 43 ++++++++++++++++++++--- api/client/commit.go | 2 +- api/client/cp.go | 2 +- api/client/create.go | 2 +- api/client/diff.go | 2 +- api/client/events.go | 2 +- api/client/exec.go | 2 +- api/client/export.go | 2 +- api/client/history.go | 2 +- api/client/images.go | 2 +- api/client/import.go | 2 +- api/client/info.go | 2 +- api/client/inspect.go | 2 +- api/client/kill.go | 2 +- api/client/load.go | 2 +- api/client/login.go | 2 +- api/client/logout.go | 2 +- api/client/logs.go | 2 +- api/client/pause.go | 2 +- api/client/port.go | 2 +- api/client/ps.go | 2 +- api/client/pull.go | 2 +- api/client/push.go | 2 +- api/client/rename.go | 2 +- api/client/restart.go | 2 +- api/client/rm.go | 2 +- api/client/rmi.go | 2 +- api/client/run.go | 2 +- api/client/save.go | 2 +- api/client/search.go | 2 +- api/client/start.go | 2 +- api/client/stats.go | 2 +- api/client/stop.go | 2 +- api/client/tag.go | 2 +- api/client/top.go | 2 +- api/client/unpause.go | 2 +- api/client/version.go | 2 +- api/client/wait.go | 2 +- integration-cli/docker_cli_help_test.go | 2 +- integration-cli/docker_cli_search_test.go | 2 +- 42 files changed, 79 insertions(+), 46 deletions(-) diff --git a/api/client/attach.go b/api/client/attach.go index 8ab3248ace..059ff1332a 100644 --- a/api/client/attach.go +++ b/api/client/attach.go @@ -17,7 +17,7 @@ import ( // Usage: docker attach [OPTIONS] CONTAINER func (cli *DockerCli) CmdAttach(args ...string) error { var ( - cmd = cli.Subcmd("attach", "CONTAINER", "Attach to a running container", true) + cmd = cli.Subcmd("attach", []string{"CONTAINER"}, "Attach to a running container", true) noStdin = cmd.Bool([]string{"#nostdin", "-no-stdin"}, false, "Do not attach STDIN") proxy = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy all received signals to the process") ) diff --git a/api/client/build.go b/api/client/build.go index 23424c4c0f..ebe48b097f 100644 --- a/api/client/build.go +++ b/api/client/build.go @@ -43,7 +43,7 @@ const ( // // Usage: docker build [OPTIONS] PATH | URL | - func (cli *DockerCli) CmdBuild(args ...string) error { - cmd := cli.Subcmd("build", "PATH | URL | -", "Build a new image from the source code at PATH", true) + cmd := cli.Subcmd("build", []string{"PATH | URL | -"}, "Build a new image from the source code at PATH", true) tag := cmd.String([]string{"t", "-tag"}, "", "Repository name (and optionally a tag) for the image") suppressOutput := cmd.Bool([]string{"q", "-quiet"}, false, "Suppress the verbose output generated by the containers") noCache := cmd.Bool([]string{"#no-cache", "-no-cache"}, false, "Do not use cache when building the image") diff --git a/api/client/cli.go b/api/client/cli.go index 65564fe9e8..84574fd3ce 100644 --- a/api/client/cli.go +++ b/api/client/cli.go @@ -107,29 +107,62 @@ func (cli *DockerCli) Cmd(args ...string) error { // A subcommand represents an action that can be performed // from the Docker command line client. // +// Multiple subcommand synopses may be provided with one 'Usage' line being +// printed for each in the following way: +// +// Usage: docker [OPTIONS] +// docker [OPTIONS] +// ... +// +// If no undeprecated flags are added to the returned FlagSet, "[OPTIONS]" will +// not be included on the usage synopsis lines. If no synopses are given, only +// one usage synopsis line will be printed with nothing following the +// "[OPTIONS]" section +// // To see all available subcommands, run "docker --help". -func (cli *DockerCli) Subcmd(name, signature, description string, exitOnError bool) *flag.FlagSet { +func (cli *DockerCli) Subcmd(name string, synopses []string, description string, exitOnError bool) *flag.FlagSet { var errorHandling flag.ErrorHandling if exitOnError { errorHandling = flag.ExitOnError } else { errorHandling = flag.ContinueOnError } + flags := flag.NewFlagSet(name, errorHandling) - if signature != "" { - signature = " " + signature - } + flags.Usage = func() { flags.ShortUsage() flags.PrintDefaults() } + flags.ShortUsage = func() { options := "" if flags.FlagCountUndeprecated() > 0 { options = " [OPTIONS]" } - fmt.Fprintf(flags.Out(), "\nUsage: docker %s%s%s\n\n%s\n", name, options, signature, description) + + if len(synopses) == 0 { + synopses = []string{""} + } + + // Allow for multiple command usage synopses. + for i, synopsis := range synopses { + lead := "\t" + if i == 0 { + // First line needs the word 'Usage'. + lead = "Usage:\t" + } + + if synopsis != "" { + synopsis = " " + synopsis + } + + fmt.Fprintf(flags.Out(), "\n%sdocker %s%s%s", lead, name, options, synopsis) + } + + fmt.Fprintf(flags.Out(), "\n\n%s\n", description) } + return flags } diff --git a/api/client/commit.go b/api/client/commit.go index dd1d24f13b..52a41ccedb 100644 --- a/api/client/commit.go +++ b/api/client/commit.go @@ -17,7 +17,7 @@ import ( // // Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] func (cli *DockerCli) CmdCommit(args ...string) error { - cmd := cli.Subcmd("commit", "CONTAINER [REPOSITORY[:TAG]]", "Create a new image from a container's changes", true) + cmd := cli.Subcmd("commit", []string{"CONTAINER [REPOSITORY[:TAG]]"}, "Create a new image from a container's changes", true) flPause := cmd.Bool([]string{"p", "-pause"}, true, "Pause container during commit") flComment := cmd.String([]string{"m", "-message"}, "", "Commit message") flAuthor := cmd.String([]string{"a", "#author", "-author"}, "", "Author (e.g., \"John Hannibal Smith \")") diff --git a/api/client/cp.go b/api/client/cp.go index d195601ba6..d5bd436af9 100644 --- a/api/client/cp.go +++ b/api/client/cp.go @@ -16,7 +16,7 @@ import ( // // Usage: docker cp CONTAINER:PATH HOSTDIR func (cli *DockerCli) CmdCp(args ...string) error { - cmd := cli.Subcmd("cp", "CONTAINER:PATH HOSTDIR|-", "Copy files/folders from a PATH on the container to a HOSTDIR on the host\nrunning the command. Use '-' to write the data as a tar file to STDOUT.", true) + cmd := cli.Subcmd("cp", []string{"CONTAINER:PATH HOSTDIR|-"}, "Copy files/folders from a PATH on the container to a HOSTDIR on the host\nrunning the command. Use '-' to write the data as a tar file to STDOUT.", true) cmd.Require(flag.Exact, 2) cmd.ParseFlags(args, true) diff --git a/api/client/create.go b/api/client/create.go index 475c50660a..25be6c48a1 100644 --- a/api/client/create.go +++ b/api/client/create.go @@ -135,7 +135,7 @@ func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runc // // Usage: docker create [OPTIONS] IMAGE [COMMAND] [ARG...] func (cli *DockerCli) CmdCreate(args ...string) error { - cmd := cli.Subcmd("create", "IMAGE [COMMAND] [ARG...]", "Create a new container", true) + cmd := cli.Subcmd("create", []string{"IMAGE [COMMAND] [ARG...]"}, "Create a new container", true) // These are flags not stored in Config/HostConfig var ( diff --git a/api/client/diff.go b/api/client/diff.go index 6000c6b388..c8fec96e76 100644 --- a/api/client/diff.go +++ b/api/client/diff.go @@ -17,7 +17,7 @@ import ( // // Usage: docker diff CONTAINER func (cli *DockerCli) CmdDiff(args ...string) error { - cmd := cli.Subcmd("diff", "CONTAINER", "Inspect changes on a container's filesystem", true) + cmd := cli.Subcmd("diff", []string{"CONTAINER"}, "Inspect changes on a container's filesystem", true) cmd.Require(flag.Exact, 1) cmd.ParseFlags(args, true) diff --git a/api/client/events.go b/api/client/events.go index d3e235093e..ee2932a433 100644 --- a/api/client/events.go +++ b/api/client/events.go @@ -14,7 +14,7 @@ import ( // // Usage: docker events [OPTIONS] func (cli *DockerCli) CmdEvents(args ...string) error { - cmd := cli.Subcmd("events", "", "Get real time events from the server", true) + cmd := cli.Subcmd("events", nil, "Get real time events from the server", true) since := cmd.String([]string{"#since", "-since"}, "", "Show all events created since timestamp") until := cmd.String([]string{"-until"}, "", "Stream events until this timestamp") flFilter := opts.NewListOpts(nil) diff --git a/api/client/exec.go b/api/client/exec.go index f247ec5217..69643b7f8d 100644 --- a/api/client/exec.go +++ b/api/client/exec.go @@ -15,7 +15,7 @@ import ( // // Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...] func (cli *DockerCli) CmdExec(args ...string) error { - cmd := cli.Subcmd("exec", "CONTAINER COMMAND [ARG...]", "Run a command in a running container", true) + cmd := cli.Subcmd("exec", []string{"CONTAINER COMMAND [ARG...]"}, "Run a command in a running container", true) execConfig, err := runconfig.ParseExec(cmd, args) // just in case the ParseExec does not exit diff --git a/api/client/export.go b/api/client/export.go index 42b0834739..bda7991fdd 100644 --- a/api/client/export.go +++ b/api/client/export.go @@ -14,7 +14,7 @@ import ( // // Usage: docker export [OPTIONS] CONTAINER func (cli *DockerCli) CmdExport(args ...string) error { - cmd := cli.Subcmd("export", "CONTAINER", "Export a filesystem as a tar archive (streamed to STDOUT by default)", true) + cmd := cli.Subcmd("export", []string{"CONTAINER"}, "Export a filesystem as a tar archive (streamed to STDOUT by default)", true) outfile := cmd.String([]string{"o", "-output"}, "", "Write to a file, instead of STDOUT") cmd.Require(flag.Exact, 1) diff --git a/api/client/history.go b/api/client/history.go index 31b8535031..3227fc57a7 100644 --- a/api/client/history.go +++ b/api/client/history.go @@ -17,7 +17,7 @@ import ( // // Usage: docker history [OPTIONS] IMAGE func (cli *DockerCli) CmdHistory(args ...string) error { - cmd := cli.Subcmd("history", "IMAGE", "Show the history of an image", true) + cmd := cli.Subcmd("history", []string{"IMAGE"}, "Show the history of an image", true) human := cmd.Bool([]string{"H", "-human"}, true, "Print sizes and dates in human readable format") quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs") noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output") diff --git a/api/client/images.go b/api/client/images.go index e39c473749..5cb89889ba 100644 --- a/api/client/images.go +++ b/api/client/images.go @@ -21,7 +21,7 @@ import ( // // Usage: docker images [OPTIONS] [REPOSITORY] func (cli *DockerCli) CmdImages(args ...string) error { - cmd := cli.Subcmd("images", "[REPOSITORY]", "List images", true) + cmd := cli.Subcmd("images", []string{"[REPOSITORY]"}, "List images", true) quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs") all := cmd.Bool([]string{"a", "-all"}, false, "Show all images (default hides intermediate images)") noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output") diff --git a/api/client/import.go b/api/client/import.go index 48c56896af..102578eaf5 100644 --- a/api/client/import.go +++ b/api/client/import.go @@ -17,7 +17,7 @@ import ( // // Usage: docker import [OPTIONS] URL [REPOSITORY[:TAG]] func (cli *DockerCli) CmdImport(args ...string) error { - 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) + cmd := cli.Subcmd("import", []string{"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) flChanges := opts.NewListOpts(nil) cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image") cmd.Require(flag.Min, 1) diff --git a/api/client/info.go b/api/client/info.go index b3bdc26d57..e90033a014 100644 --- a/api/client/info.go +++ b/api/client/info.go @@ -14,7 +14,7 @@ import ( // // Usage: docker info func (cli *DockerCli) CmdInfo(args ...string) error { - cmd := cli.Subcmd("info", "", "Display system-wide information", true) + cmd := cli.Subcmd("info", nil, "Display system-wide information", true) cmd.Require(flag.Exact, 0) cmd.ParseFlags(args, true) diff --git a/api/client/inspect.go b/api/client/inspect.go index 734d239759..1f72b9174b 100644 --- a/api/client/inspect.go +++ b/api/client/inspect.go @@ -16,7 +16,7 @@ import ( // // Usage: docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...] func (cli *DockerCli) CmdInspect(args ...string) error { - cmd := cli.Subcmd("inspect", "CONTAINER|IMAGE [CONTAINER|IMAGE...]", "Return low-level information on a container or image", true) + cmd := cli.Subcmd("inspect", []string{"CONTAINER|IMAGE [CONTAINER|IMAGE...]"}, "Return low-level information on a container or image", true) tmplStr := cmd.String([]string{"f", "#format", "-format"}, "", "Format the output using the given go template") cmd.Require(flag.Min, 1) diff --git a/api/client/kill.go b/api/client/kill.go index becff3b7e0..4f3d7ad0bd 100644 --- a/api/client/kill.go +++ b/api/client/kill.go @@ -10,7 +10,7 @@ import ( // // Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...] func (cli *DockerCli) CmdKill(args ...string) error { - cmd := cli.Subcmd("kill", "CONTAINER [CONTAINER...]", "Kill a running container using SIGKILL or a specified signal", true) + cmd := cli.Subcmd("kill", []string{"CONTAINER [CONTAINER...]"}, "Kill a running container using SIGKILL or a specified signal", true) signal := cmd.String([]string{"s", "-signal"}, "KILL", "Signal to send to the container") cmd.Require(flag.Min, 1) diff --git a/api/client/load.go b/api/client/load.go index 8dd8bb5469..47350545fe 100644 --- a/api/client/load.go +++ b/api/client/load.go @@ -13,7 +13,7 @@ import ( // // Usage: docker load [OPTIONS] func (cli *DockerCli) CmdLoad(args ...string) error { - cmd := cli.Subcmd("load", "", "Load an image from a tar archive on STDIN", true) + cmd := cli.Subcmd("load", nil, "Load an image from a tar archive on STDIN", true) infile := cmd.String([]string{"i", "-input"}, "", "Read from a tar archive file, instead of STDIN") cmd.Require(flag.Exact, 0) diff --git a/api/client/login.go b/api/client/login.go index d7da1de2b0..a33ca6d7ec 100644 --- a/api/client/login.go +++ b/api/client/login.go @@ -21,7 +21,7 @@ import ( // // Usage: docker login SERVER func (cli *DockerCli) CmdLogin(args ...string) error { - cmd := cli.Subcmd("login", "[SERVER]", "Register or log in to a Docker registry server, if no server is\nspecified \""+registry.IndexServerAddress()+"\" is the default.", true) + cmd := cli.Subcmd("login", []string{"[SERVER]"}, "Register or log in to a Docker registry server, if no server is\nspecified \""+registry.IndexServerAddress()+"\" is the default.", true) cmd.Require(flag.Max, 1) var username, password, email string diff --git a/api/client/logout.go b/api/client/logout.go index a571af2cff..482261aed4 100644 --- a/api/client/logout.go +++ b/api/client/logout.go @@ -13,7 +13,7 @@ import ( // // Usage: docker logout [SERVER] func (cli *DockerCli) CmdLogout(args ...string) error { - cmd := cli.Subcmd("logout", "[SERVER]", "Log out from a Docker registry, if no server is\nspecified \""+registry.IndexServerAddress()+"\" is the default.", true) + cmd := cli.Subcmd("logout", []string{"[SERVER]"}, "Log out from a Docker registry, if no server is\nspecified \""+registry.IndexServerAddress()+"\" is the default.", true) cmd.Require(flag.Max, 1) cmd.ParseFlags(args, true) diff --git a/api/client/logs.go b/api/client/logs.go index c7e48bb5a9..ac35f30a38 100644 --- a/api/client/logs.go +++ b/api/client/logs.go @@ -16,7 +16,7 @@ import ( // docker logs [OPTIONS] CONTAINER func (cli *DockerCli) CmdLogs(args ...string) error { var ( - cmd = cli.Subcmd("logs", "CONTAINER", "Fetch the logs of a container", true) + cmd = cli.Subcmd("logs", []string{"CONTAINER"}, "Fetch the logs of a container", true) follow = cmd.Bool([]string{"f", "-follow"}, false, "Follow log output") since = cmd.String([]string{"-since"}, "", "Show logs since timestamp") times = cmd.Bool([]string{"t", "-timestamps"}, false, "Show timestamps") diff --git a/api/client/pause.go b/api/client/pause.go index ee690c77fa..0612863da7 100644 --- a/api/client/pause.go +++ b/api/client/pause.go @@ -10,7 +10,7 @@ import ( // // Usage: docker pause CONTAINER [CONTAINER...] func (cli *DockerCli) CmdPause(args ...string) error { - cmd := cli.Subcmd("pause", "CONTAINER [CONTAINER...]", "Pause all processes within a container", true) + cmd := cli.Subcmd("pause", []string{"CONTAINER [CONTAINER...]"}, "Pause all processes within a container", true) cmd.Require(flag.Min, 1) cmd.ParseFlags(args, true) diff --git a/api/client/port.go b/api/client/port.go index 4c39314706..52a3fff197 100644 --- a/api/client/port.go +++ b/api/client/port.go @@ -14,7 +14,7 @@ import ( // // Usage: docker port CONTAINER [PRIVATE_PORT[/PROTO]] func (cli *DockerCli) CmdPort(args ...string) error { - cmd := cli.Subcmd("port", "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) + 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) cmd.Require(flag.Min, 1) cmd.ParseFlags(args, true) diff --git a/api/client/ps.go b/api/client/ps.go index 6c40c6867b..999b418273 100644 --- a/api/client/ps.go +++ b/api/client/ps.go @@ -29,7 +29,7 @@ func (cli *DockerCli) CmdPs(args ...string) error { psFilterArgs = filters.Args{} v = url.Values{} - cmd = cli.Subcmd("ps", "", "List containers", true) + cmd = cli.Subcmd("ps", nil, "List containers", true) quiet = cmd.Bool([]string{"q", "-quiet"}, false, "Only display numeric IDs") size = cmd.Bool([]string{"s", "-size"}, false, "Display total file sizes") all = cmd.Bool([]string{"a", "-all"}, false, "Show all containers (default shows just running)") diff --git a/api/client/pull.go b/api/client/pull.go index 4be30b4e6f..b2e064bc50 100644 --- a/api/client/pull.go +++ b/api/client/pull.go @@ -15,7 +15,7 @@ import ( // // Usage: docker pull [OPTIONS] IMAGENAME[:TAG|@DIGEST] func (cli *DockerCli) CmdPull(args ...string) error { - cmd := cli.Subcmd("pull", "NAME[:TAG|@DIGEST]", "Pull an image or a repository from the registry", true) + cmd := cli.Subcmd("pull", []string{"NAME[:TAG|@DIGEST]"}, "Pull an image or a repository from the registry", true) allTags := cmd.Bool([]string{"a", "-all-tags"}, false, "Download all tagged images in the repository") cmd.Require(flag.Exact, 1) diff --git a/api/client/push.go b/api/client/push.go index dc4266cb75..632fde3712 100644 --- a/api/client/push.go +++ b/api/client/push.go @@ -13,7 +13,7 @@ import ( // // Usage: docker push NAME[:TAG] func (cli *DockerCli) CmdPush(args ...string) error { - cmd := cli.Subcmd("push", "NAME[:TAG]", "Push an image or a repository to the registry", true) + cmd := cli.Subcmd("push", []string{"NAME[:TAG]"}, "Push an image or a repository to the registry", true) cmd.Require(flag.Exact, 1) cmd.ParseFlags(args, true) diff --git a/api/client/rename.go b/api/client/rename.go index ebe16963dd..04cf258648 100644 --- a/api/client/rename.go +++ b/api/client/rename.go @@ -10,7 +10,7 @@ import ( // // Usage: docker rename OLD_NAME NEW_NAME func (cli *DockerCli) CmdRename(args ...string) error { - cmd := cli.Subcmd("rename", "OLD_NAME NEW_NAME", "Rename a container", true) + cmd := cli.Subcmd("rename", []string{"OLD_NAME NEW_NAME"}, "Rename a container", true) cmd.Require(flag.Exact, 2) cmd.ParseFlags(args, true) diff --git a/api/client/restart.go b/api/client/restart.go index c769fb6d27..3dc6a650c3 100644 --- a/api/client/restart.go +++ b/api/client/restart.go @@ -12,7 +12,7 @@ import ( // // Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...] func (cli *DockerCli) CmdRestart(args ...string) error { - cmd := cli.Subcmd("restart", "CONTAINER [CONTAINER...]", "Restart a running container", true) + cmd := cli.Subcmd("restart", []string{"CONTAINER [CONTAINER...]"}, "Restart a running container", true) nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing the container") cmd.Require(flag.Min, 1) diff --git a/api/client/rm.go b/api/client/rm.go index e6f3aeaeba..fe5d241210 100644 --- a/api/client/rm.go +++ b/api/client/rm.go @@ -12,7 +12,7 @@ import ( // // Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...] func (cli *DockerCli) CmdRm(args ...string) error { - cmd := cli.Subcmd("rm", "CONTAINER [CONTAINER...]", "Remove one or more containers", true) + cmd := cli.Subcmd("rm", []string{"CONTAINER [CONTAINER...]"}, "Remove one or more containers", true) v := cmd.Bool([]string{"v", "-volumes"}, false, "Remove the volumes associated with the container") link := cmd.Bool([]string{"l", "#link", "-link"}, false, "Remove the specified link") force := cmd.Bool([]string{"f", "-force"}, false, "Force the removal of a running container (uses SIGKILL)") diff --git a/api/client/rmi.go b/api/client/rmi.go index 36f2036d13..4ba32b45c7 100644 --- a/api/client/rmi.go +++ b/api/client/rmi.go @@ -14,7 +14,7 @@ import ( // Usage: docker rmi [OPTIONS] IMAGE [IMAGE...] func (cli *DockerCli) CmdRmi(args ...string) error { var ( - cmd = cli.Subcmd("rmi", "IMAGE [IMAGE...]", "Remove one or more images", true) + cmd = cli.Subcmd("rmi", []string{"IMAGE [IMAGE...]"}, "Remove one or more images", true) force = cmd.Bool([]string{"f", "-force"}, false, "Force removal of the image") noprune = cmd.Bool([]string{"-no-prune"}, false, "Do not delete untagged parents") ) diff --git a/api/client/run.go b/api/client/run.go index c4eb528eb5..cca63af770 100644 --- a/api/client/run.go +++ b/api/client/run.go @@ -38,7 +38,7 @@ func (cid *cidFile) Write(id string) error { // // Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] func (cli *DockerCli) CmdRun(args ...string) error { - cmd := cli.Subcmd("run", "IMAGE [COMMAND] [ARG...]", "Run a command in a new container", true) + cmd := cli.Subcmd("run", []string{"IMAGE [COMMAND] [ARG...]"}, "Run a command in a new container", true) // These are flags not stored in Config/HostConfig var ( diff --git a/api/client/save.go b/api/client/save.go index a04cbcf1e9..2d3d296540 100644 --- a/api/client/save.go +++ b/api/client/save.go @@ -15,7 +15,7 @@ import ( // // Usage: docker save [OPTIONS] IMAGE [IMAGE...] func (cli *DockerCli) CmdSave(args ...string) error { - cmd := cli.Subcmd("save", "IMAGE [IMAGE...]", "Save an image(s) to a tar archive (streamed to STDOUT by default)", true) + cmd := cli.Subcmd("save", []string{"IMAGE [IMAGE...]"}, "Save an image(s) to a tar archive (streamed to STDOUT by default)", true) outfile := cmd.String([]string{"o", "-output"}, "", "Write to an file, instead of STDOUT") cmd.Require(flag.Min, 1) diff --git a/api/client/search.go b/api/client/search.go index e606d479f1..02c1f7d556 100644 --- a/api/client/search.go +++ b/api/client/search.go @@ -25,7 +25,7 @@ func (r ByStars) Less(i, j int) bool { return r[i].StarCount < r[j].StarCount } // // Usage: docker search [OPTIONS] TERM func (cli *DockerCli) CmdSearch(args ...string) error { - cmd := cli.Subcmd("search", "TERM", "Search the Docker Hub for images", true) + cmd := cli.Subcmd("search", []string{"TERM"}, "Search the Docker Hub for images", true) noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output") trusted := cmd.Bool([]string{"#t", "#trusted", "#-trusted"}, false, "Only show trusted builds") automated := cmd.Bool([]string{"-automated"}, false, "Only show automated builds") diff --git a/api/client/start.go b/api/client/start.go index 40f84d7cf3..b73a2a5d9f 100644 --- a/api/client/start.go +++ b/api/client/start.go @@ -48,7 +48,7 @@ func (cli *DockerCli) CmdStart(args ...string) error { cErr chan error tty bool - cmd = cli.Subcmd("start", "CONTAINER [CONTAINER...]", "Start one or more stopped containers", true) + cmd = cli.Subcmd("start", []string{"CONTAINER [CONTAINER...]"}, "Start one or more stopped containers", true) attach = cmd.Bool([]string{"a", "-attach"}, false, "Attach STDOUT/STDERR and forward signals") openStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Attach container's STDIN") ) diff --git a/api/client/stats.go b/api/client/stats.go index 592da553c1..20b5630b4b 100644 --- a/api/client/stats.go +++ b/api/client/stats.go @@ -122,7 +122,7 @@ func (s *containerStats) Display(w io.Writer) error { // // Usage: docker stats CONTAINER [CONTAINER...] func (cli *DockerCli) CmdStats(args ...string) error { - cmd := cli.Subcmd("stats", "CONTAINER [CONTAINER...]", "Display a live stream of one or more containers' resource usage statistics", true) + cmd := cli.Subcmd("stats", []string{"CONTAINER [CONTAINER...]"}, "Display a live stream of one or more containers' resource usage statistics", true) noStream := cmd.Bool([]string{"-no-stream"}, false, "Disable streaming stats and only pull the first result") cmd.Require(flag.Min, 1) cmd.ParseFlags(args, true) diff --git a/api/client/stop.go b/api/client/stop.go index 9551911ffd..ee9ce3bffe 100644 --- a/api/client/stop.go +++ b/api/client/stop.go @@ -14,7 +14,7 @@ import ( // // Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...] func (cli *DockerCli) CmdStop(args ...string) error { - cmd := cli.Subcmd("stop", "CONTAINER [CONTAINER...]", "Stop a running container by sending SIGTERM and then SIGKILL after a\ngrace period", true) + cmd := cli.Subcmd("stop", []string{"CONTAINER [CONTAINER...]"}, "Stop a running container by sending SIGTERM and then SIGKILL after a\ngrace period", true) nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing it") cmd.Require(flag.Min, 1) diff --git a/api/client/tag.go b/api/client/tag.go index 56541f86d4..287d3e7cb6 100644 --- a/api/client/tag.go +++ b/api/client/tag.go @@ -12,7 +12,7 @@ import ( // // Usage: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG] func (cli *DockerCli) CmdTag(args ...string) error { - cmd := cli.Subcmd("tag", "IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]", "Tag an image into a repository", true) + cmd := cli.Subcmd("tag", []string{"IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]"}, "Tag an image into a repository", true) force := cmd.Bool([]string{"f", "#force", "-force"}, false, "Force") cmd.Require(flag.Exact, 2) diff --git a/api/client/top.go b/api/client/top.go index ee16fdbf60..58e797512b 100644 --- a/api/client/top.go +++ b/api/client/top.go @@ -15,7 +15,7 @@ import ( // // Usage: docker top CONTAINER func (cli *DockerCli) CmdTop(args ...string) error { - cmd := cli.Subcmd("top", "CONTAINER [ps OPTIONS]", "Display the running processes of a container", true) + cmd := cli.Subcmd("top", []string{"CONTAINER [ps OPTIONS]"}, "Display the running processes of a container", true) cmd.Require(flag.Min, 1) cmd.ParseFlags(args, true) diff --git a/api/client/unpause.go b/api/client/unpause.go index 428dfec998..ca7aad4e98 100644 --- a/api/client/unpause.go +++ b/api/client/unpause.go @@ -10,7 +10,7 @@ import ( // // Usage: docker unpause CONTAINER [CONTAINER...] func (cli *DockerCli) CmdUnpause(args ...string) error { - cmd := cli.Subcmd("unpause", "CONTAINER [CONTAINER...]", "Unpause all processes within a container", true) + cmd := cli.Subcmd("unpause", []string{"CONTAINER [CONTAINER...]"}, "Unpause all processes within a container", true) cmd.Require(flag.Min, 1) cmd.ParseFlags(args, true) diff --git a/api/client/version.go b/api/client/version.go index 29e714da8b..d7079c404e 100644 --- a/api/client/version.go +++ b/api/client/version.go @@ -18,7 +18,7 @@ import ( // // Usage: docker version func (cli *DockerCli) CmdVersion(args ...string) error { - cmd := cli.Subcmd("version", "", "Show the Docker version information.", true) + cmd := cli.Subcmd("version", nil, "Show the Docker version information.", true) cmd.Require(flag.Exact, 0) cmd.ParseFlags(args, true) diff --git a/api/client/wait.go b/api/client/wait.go index bfec19e24b..068f0f1262 100644 --- a/api/client/wait.go +++ b/api/client/wait.go @@ -12,7 +12,7 @@ import ( // // Usage: docker wait CONTAINER [CONTAINER...] func (cli *DockerCli) CmdWait(args ...string) error { - cmd := cli.Subcmd("wait", "CONTAINER [CONTAINER...]", "Block until a container stops, then print its exit code.", true) + cmd := cli.Subcmd("wait", []string{"CONTAINER [CONTAINER...]"}, "Block until a container stops, then print its exit code.", true) cmd.Require(flag.Min, 1) cmd.ParseFlags(args, true) diff --git a/integration-cli/docker_cli_help_test.go b/integration-cli/docker_cli_help_test.go index da57601c15..ce9f54e69a 100644 --- a/integration-cli/docker_cli_help_test.go +++ b/integration-cli/docker_cli_help_test.go @@ -215,7 +215,7 @@ func (s *DockerSuite) TestHelpTextVerify(c *check.C) { c.Fatalf("Bad output from %q\nstdout:%q\nstderr:%q\nec:%d\nerr:%q", args, stdout, stderr, ec, err) } // Should have just short usage - if !strings.Contains(stderr, "\nUsage: ") { + if !strings.Contains(stderr, "\nUsage:\t") { c.Fatalf("Missing short usage on %q\nstderr:%q", args, stderr) } // But shouldn't have full usage diff --git a/integration-cli/docker_cli_search_test.go b/integration-cli/docker_cli_search_test.go index da298a1e0c..f689bba96d 100644 --- a/integration-cli/docker_cli_search_test.go +++ b/integration-cli/docker_cli_search_test.go @@ -53,7 +53,7 @@ func (s *DockerSuite) TestSearchCmdOptions(c *check.C) { c.Fatalf("failed to get search help information: %s, %v", out, err) } - if !strings.Contains(out, "Usage: docker search [OPTIONS] TERM") { + if !strings.Contains(out, "Usage:\tdocker search [OPTIONS] TERM") { c.Fatalf("failed to show docker search usage: %s, %v", out, err) }