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,14 +21,16 @@ 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")
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"},
{"download", "Download a layer from a remote location"},
{"upload", "Upload a layer"},
{"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"},
@ -38,6 +40,13 @@ func (docker *Docker) CmdUsage(stdin io.ReadCloser, stdout io.Writer, args ...st
} {
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
}