help.go 737 B

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