mirror of https://github.com/docker/cli.git
move orchestration commands to their own section in --help output
This groups all swarm-related subcommands to their own section in the --help output, to make it clearer which commands require swarm to be enabled With this change: Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Options: --config string Location of client config files (default "/Users/sebastiaan/.docker") -c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use") -D, --debug Enable debug mode -H, --host list Daemon socket(s) to connect to -l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info") --tls Use TLS; implied by --tlsverify --tlscacert string Trust certs signed only by this CA (default "/Users/sebastiaan/.docker/ca.pem") --tlscert string Path to TLS certificate file (default "/Users/sebastiaan/.docker/cert.pem") --tlskey string Path to TLS key file (default "/Users/sebastiaan/.docker/key.pem") --tlsverify Use TLS and verify the remote -v, --version Print version information and quit Management Commands: builder Manage builds buildx* Docker Buildx (Docker Inc., v0.8.1) checkpoint Manage checkpoints completion Generate the autocompletion script for the specified shell compose* Docker Compose (Docker Inc., v2.3.3) container Manage containers context Manage contexts image Manage images manifest Manage Docker image manifests and manifest lists network Manage networks plugin Manage plugins scan* Docker Scan (Docker Inc., v0.17.0) system Manage Docker trust Manage trust on Docker images volume Manage volumes Orchestration Commands: config Manage Swarm configs node Manage Swarm nodes secret Manage Swarm secrets service Manage Swarm services stack Manage Swarm stacks swarm Manage Swarm Commands: attach Attach local standard input, output, and error streams to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save one or more images to a tar archive (streamed to STDOUT by default) search Search the Docker Hub for images start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop one or more running containers tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE top Display the running processes of a container unpause Unpause all processes within one or more containers update Update configuration of one or more containers version Show the Docker version information wait Block until one or more containers stop, then print their exit codes Run 'docker COMMAND --help' for more information on a command. To get more help with docker, check out our guides at https://docs.docker.com/go/guides/ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
bb610a59b4
commit
ae611f4c07
36
cli/cobra.go
36
cli/cobra.go
|
@ -31,9 +31,11 @@ func setupCommonRootCommand(rootCmd *cobra.Command) (*cliflags.ClientOptions, *p
|
||||||
cobra.AddTemplateFunc("add", func(a, b int) int { return a + b })
|
cobra.AddTemplateFunc("add", func(a, b int) int { return a + b })
|
||||||
cobra.AddTemplateFunc("hasSubCommands", hasSubCommands)
|
cobra.AddTemplateFunc("hasSubCommands", hasSubCommands)
|
||||||
cobra.AddTemplateFunc("hasManagementSubCommands", hasManagementSubCommands)
|
cobra.AddTemplateFunc("hasManagementSubCommands", hasManagementSubCommands)
|
||||||
|
cobra.AddTemplateFunc("hasOrchestratorSubCommands", hasOrchestratorSubCommands)
|
||||||
cobra.AddTemplateFunc("hasInvalidPlugins", hasInvalidPlugins)
|
cobra.AddTemplateFunc("hasInvalidPlugins", hasInvalidPlugins)
|
||||||
cobra.AddTemplateFunc("operationSubCommands", operationSubCommands)
|
cobra.AddTemplateFunc("operationSubCommands", operationSubCommands)
|
||||||
cobra.AddTemplateFunc("managementSubCommands", managementSubCommands)
|
cobra.AddTemplateFunc("managementSubCommands", managementSubCommands)
|
||||||
|
cobra.AddTemplateFunc("orchestratorSubCommands", orchestratorSubCommands)
|
||||||
cobra.AddTemplateFunc("invalidPlugins", invalidPlugins)
|
cobra.AddTemplateFunc("invalidPlugins", invalidPlugins)
|
||||||
cobra.AddTemplateFunc("wrappedFlagUsages", wrappedFlagUsages)
|
cobra.AddTemplateFunc("wrappedFlagUsages", wrappedFlagUsages)
|
||||||
cobra.AddTemplateFunc("vendorAndVersion", vendorAndVersion)
|
cobra.AddTemplateFunc("vendorAndVersion", vendorAndVersion)
|
||||||
|
@ -240,6 +242,10 @@ func hasManagementSubCommands(cmd *cobra.Command) bool {
|
||||||
return len(managementSubCommands(cmd)) > 0
|
return len(managementSubCommands(cmd)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hasOrchestratorSubCommands(cmd *cobra.Command) bool {
|
||||||
|
return len(orchestratorSubCommands(cmd)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
func hasInvalidPlugins(cmd *cobra.Command) bool {
|
func hasInvalidPlugins(cmd *cobra.Command) bool {
|
||||||
return len(invalidPlugins(cmd)) > 0
|
return len(invalidPlugins(cmd)) > 0
|
||||||
}
|
}
|
||||||
|
@ -285,6 +291,27 @@ func vendorAndVersion(cmd *cobra.Command) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func managementSubCommands(cmd *cobra.Command) []*cobra.Command {
|
func managementSubCommands(cmd *cobra.Command) []*cobra.Command {
|
||||||
|
cmds := []*cobra.Command{}
|
||||||
|
for _, sub := range allManagementSubCommands(cmd) {
|
||||||
|
if _, ok := sub.Annotations["swarm"]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cmds = append(cmds, sub)
|
||||||
|
}
|
||||||
|
return cmds
|
||||||
|
}
|
||||||
|
|
||||||
|
func orchestratorSubCommands(cmd *cobra.Command) []*cobra.Command {
|
||||||
|
cmds := []*cobra.Command{}
|
||||||
|
for _, sub := range allManagementSubCommands(cmd) {
|
||||||
|
if _, ok := sub.Annotations["swarm"]; ok {
|
||||||
|
cmds = append(cmds, sub)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cmds
|
||||||
|
}
|
||||||
|
|
||||||
|
func allManagementSubCommands(cmd *cobra.Command) []*cobra.Command {
|
||||||
cmds := []*cobra.Command{}
|
cmds := []*cobra.Command{}
|
||||||
for _, sub := range cmd.Commands() {
|
for _, sub := range cmd.Commands() {
|
||||||
if isPlugin(sub) {
|
if isPlugin(sub) {
|
||||||
|
@ -359,6 +386,15 @@ Management Commands:
|
||||||
{{rpad (decoratedName .) (add .NamePadding 1)}}{{.Short}}{{ if isPlugin .}} {{vendorAndVersion .}}{{ end}}
|
{{rpad (decoratedName .) (add .NamePadding 1)}}{{.Short}}{{ if isPlugin .}} {{vendorAndVersion .}}{{ end}}
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
|
||||||
|
{{- end}}
|
||||||
|
{{- if hasOrchestratorSubCommands . }}
|
||||||
|
|
||||||
|
Orchestration Commands:
|
||||||
|
|
||||||
|
{{- range orchestratorSubCommands . }}
|
||||||
|
{{rpad (decoratedName .) (add .NamePadding 1)}}{{.Short}}{{ if isPlugin .}} {{vendorAndVersion .}}{{ end}}
|
||||||
|
{{- end}}
|
||||||
|
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{- if hasSubCommands .}}
|
{{- if hasSubCommands .}}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
func NewConfigCommand(dockerCli command.Cli) *cobra.Command {
|
func NewConfigCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "config",
|
Use: "config",
|
||||||
Short: "Manage Docker configs",
|
Short: "Manage Swarm configs",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCli.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
func NewSecretCommand(dockerCli command.Cli) *cobra.Command {
|
func NewSecretCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "secret",
|
Use: "secret",
|
||||||
Short: "Manage Docker secrets",
|
Short: "Manage Swarm secrets",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCli.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
func NewServiceCommand(dockerCli command.Cli) *cobra.Command {
|
func NewServiceCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "service",
|
Use: "service",
|
||||||
Short: "Manage services",
|
Short: "Manage Swarm services",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCli.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
func NewStackCommand(dockerCli command.Cli) *cobra.Command {
|
func NewStackCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "stack [OPTIONS]",
|
Use: "stack [OPTIONS]",
|
||||||
Short: "Manage Docker stacks",
|
Short: "Manage Swarm stacks",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: command.ShowHelp(dockerCli.Err()),
|
RunE: command.ShowHelp(dockerCli.Err()),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
|
|
|
@ -9,7 +9,7 @@ keywords: "config"
|
||||||
```markdown
|
```markdown
|
||||||
Usage: docker config COMMAND
|
Usage: docker config COMMAND
|
||||||
|
|
||||||
Manage Docker configs
|
Manage Swarm configs
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help Print usage
|
--help Print usage
|
||||||
|
|
|
@ -9,7 +9,7 @@ keywords: "secret"
|
||||||
```markdown
|
```markdown
|
||||||
Usage: docker secret COMMAND
|
Usage: docker secret COMMAND
|
||||||
|
|
||||||
Manage Docker secrets
|
Manage Swarm secrets
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help Print usage
|
--help Print usage
|
||||||
|
|
|
@ -9,7 +9,7 @@ keywords: "service"
|
||||||
```markdown
|
```markdown
|
||||||
Usage: docker service COMMAND
|
Usage: docker service COMMAND
|
||||||
|
|
||||||
Manage services
|
Manage Swarm services
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help Print usage
|
--help Print usage
|
||||||
|
@ -29,7 +29,7 @@ Run 'docker service COMMAND --help' for more information on a command.
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
Manage services.
|
Manage Swarm services.
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
>
|
>
|
||||||
|
|
|
@ -9,7 +9,7 @@ keywords: "stack"
|
||||||
```markdown
|
```markdown
|
||||||
Usage: docker stack [OPTIONS] COMMAND
|
Usage: docker stack [OPTIONS] COMMAND
|
||||||
|
|
||||||
Manage Docker stacks
|
Manage Swarm stacks
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help Print usage
|
--help Print usage
|
||||||
|
|
Loading…
Reference in New Issue