help.go 699 B

12345678910111213141516171819202122232425262728293031323334
  1. package client
  2. import (
  3. "fmt"
  4. flag "github.com/docker/docker/pkg/mflag"
  5. )
  6. // CmdHelp displays information on a Docker command.
  7. //
  8. // If more than one command is specified, information is only shown for the first command.
  9. //
  10. // Usage: docker help COMMAND or docker COMMAND --help
  11. func (cli *DockerCli) CmdHelp(args ...string) error {
  12. if len(args) > 1 {
  13. method, exists := cli.getMethod(args[:2]...)
  14. if exists {
  15. method("--help")
  16. return nil
  17. }
  18. }
  19. if len(args) > 0 {
  20. method, exists := cli.getMethod(args[0])
  21. if !exists {
  22. return fmt.Errorf("docker: '%s' is not a docker command. See 'docker --help'.", args[0])
  23. }
  24. method("--help")
  25. return nil
  26. }
  27. flag.Usage()
  28. return nil
  29. }