github.com/circular-dark/docker@v1.7.0/api/client/help.go (about)

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