1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

CLI: implemented 'docker help COMMAND'

This commit is contained in:
Solomon Hykes 2013-01-20 00:35:35 -08:00
parent 12599e1c55
commit 8aa2cb7d84

View file

@ -21,22 +21,31 @@ import (
"text/tabwriter"
)
func (docker *Docker) CmdUsage(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
fmt.Fprintf(stdout, "Usage: docker COMMAND [arg...]\n\nCommands:\n")
for _, cmd := range [][]interface{}{
{"run", "Run a command in a container"},
{"list", "Display a list of containers"},
{"layers", "Display a list of layers"},
{"download", "Download a layer from a remote location"},
{"upload", "Upload a layer"},
{"wait", "Wait for the state of a container to change"},
{"stop", "Stop a running container"},
{"logs", "Fetch the logs of a container"},
{"export", "Extract changes to a container's filesystem into a new layer"},
{"attach", "Attach to the standard inputs and outputs of a running container"},
{"info", "Display system-wide information"},
} {
fmt.Fprintf(stdout, " %-10.10s%s\n", cmd...)
func (docker *Docker) CmdHelp(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
log.Printf("Help %s\n", args)
if len(args) == 0 {
fmt.Fprintf(stdout, "Usage: docker COMMAND [arg...]\n\nA self-sufficient runtime for linux containers.\n\nCommands:\n")
for _, cmd := range [][]interface{}{
{"run", "Run a command in a container"},
{"clone", "Duplicate a container"},
{"list", "Display a list of containers"},
{"layers", "Display a list of layers"},
{"get", "Download a layer from a remote location"},
{"wait", "Wait for the state of a container to change"},
{"stop", "Stop a running container"},
{"logs", "Fetch the logs of a container"},
{"export", "Extract changes to a container's filesystem into a new layer"},
{"attach", "Attach to the standard inputs and outputs of a running container"},
{"info", "Display system-wide information"},
} {
fmt.Fprintf(stdout, " %-10.10s%s\n", cmd...)
}
} else {
if method := docker.getMethod(args[0]); method == nil {
return errors.New("No such command: " + args[0])
} else {
method(stdin, stdout, "--help")
}
}
return nil
}