2015-03-24 23:57:23 -04:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
flag "github.com/docker/docker/pkg/mflag"
|
|
|
|
)
|
|
|
|
|
2015-03-25 13:34:41 -04:00
|
|
|
// CmdHelp displays information on a Docker command.
|
|
|
|
//
|
2015-03-25 19:26:28 -04:00
|
|
|
// If more than one command is specified, information is only shown for the first command.
|
2015-03-25 13:34:41 -04:00
|
|
|
//
|
|
|
|
// Usage: docker help COMMAND or docker COMMAND --help
|
2015-03-24 23:57:23 -04:00
|
|
|
func (cli *DockerCli) CmdHelp(args ...string) error {
|
|
|
|
if len(args) > 1 {
|
|
|
|
method, exists := cli.getMethod(args[:2]...)
|
|
|
|
if exists {
|
|
|
|
method("--help")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(args) > 0 {
|
|
|
|
method, exists := cli.getMethod(args[0])
|
|
|
|
if !exists {
|
|
|
|
fmt.Fprintf(cli.err, "docker: '%s' is not a docker command. See 'docker --help'.\n", args[0])
|
|
|
|
os.Exit(1)
|
|
|
|
} else {
|
|
|
|
method("--help")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flag.Usage()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|