diff --git a/cli/cobra.go b/cli/cobra.go index 7f35abe50c..28e7005841 100644 --- a/cli/cobra.go +++ b/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("hasSubCommands", hasSubCommands) cobra.AddTemplateFunc("hasManagementSubCommands", hasManagementSubCommands) + cobra.AddTemplateFunc("hasOrchestratorSubCommands", hasOrchestratorSubCommands) cobra.AddTemplateFunc("hasInvalidPlugins", hasInvalidPlugins) cobra.AddTemplateFunc("operationSubCommands", operationSubCommands) cobra.AddTemplateFunc("managementSubCommands", managementSubCommands) + cobra.AddTemplateFunc("orchestratorSubCommands", orchestratorSubCommands) cobra.AddTemplateFunc("invalidPlugins", invalidPlugins) cobra.AddTemplateFunc("wrappedFlagUsages", wrappedFlagUsages) cobra.AddTemplateFunc("vendorAndVersion", vendorAndVersion) @@ -240,6 +242,10 @@ func hasManagementSubCommands(cmd *cobra.Command) bool { return len(managementSubCommands(cmd)) > 0 } +func hasOrchestratorSubCommands(cmd *cobra.Command) bool { + return len(orchestratorSubCommands(cmd)) > 0 +} + func hasInvalidPlugins(cmd *cobra.Command) bool { return len(invalidPlugins(cmd)) > 0 } @@ -285,6 +291,27 @@ func vendorAndVersion(cmd *cobra.Command) string { } 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{} for _, sub := range cmd.Commands() { if isPlugin(sub) { @@ -359,6 +386,15 @@ Management Commands: {{rpad (decoratedName .) (add .NamePadding 1)}}{{.Short}}{{ if isPlugin .}} {{vendorAndVersion .}}{{ end}} {{- end}} +{{- end}} +{{- if hasOrchestratorSubCommands . }} + +Orchestration Commands: + +{{- range orchestratorSubCommands . }} + {{rpad (decoratedName .) (add .NamePadding 1)}}{{.Short}}{{ if isPlugin .}} {{vendorAndVersion .}}{{ end}} +{{- end}} + {{- end}} {{- if hasSubCommands .}} diff --git a/cli/command/config/cmd.go b/cli/command/config/cmd.go index 7defe2a61e..b241229798 100644 --- a/cli/command/config/cmd.go +++ b/cli/command/config/cmd.go @@ -11,7 +11,7 @@ import ( func NewConfigCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "config", - Short: "Manage Docker configs", + Short: "Manage Swarm configs", Args: cli.NoArgs, RunE: command.ShowHelp(dockerCli.Err()), Annotations: map[string]string{ diff --git a/cli/command/secret/cmd.go b/cli/command/secret/cmd.go index a29d2def37..937fcdb150 100644 --- a/cli/command/secret/cmd.go +++ b/cli/command/secret/cmd.go @@ -11,7 +11,7 @@ import ( func NewSecretCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "secret", - Short: "Manage Docker secrets", + Short: "Manage Swarm secrets", Args: cli.NoArgs, RunE: command.ShowHelp(dockerCli.Err()), Annotations: map[string]string{ diff --git a/cli/command/service/cmd.go b/cli/command/service/cmd.go index 98af9852ab..23132d9928 100644 --- a/cli/command/service/cmd.go +++ b/cli/command/service/cmd.go @@ -11,7 +11,7 @@ import ( func NewServiceCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "service", - Short: "Manage services", + Short: "Manage Swarm services", Args: cli.NoArgs, RunE: command.ShowHelp(dockerCli.Err()), Annotations: map[string]string{ diff --git a/cli/command/stack/cmd.go b/cli/command/stack/cmd.go index f5abd79146..9e87482171 100644 --- a/cli/command/stack/cmd.go +++ b/cli/command/stack/cmd.go @@ -12,7 +12,7 @@ import ( func NewStackCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "stack [OPTIONS]", - Short: "Manage Docker stacks", + Short: "Manage Swarm stacks", Args: cli.NoArgs, RunE: command.ShowHelp(dockerCli.Err()), Annotations: map[string]string{ diff --git a/docs/reference/commandline/config.md b/docs/reference/commandline/config.md index 67329bd940..80ea03dfac 100644 --- a/docs/reference/commandline/config.md +++ b/docs/reference/commandline/config.md @@ -9,7 +9,7 @@ keywords: "config" ```markdown Usage: docker config COMMAND -Manage Docker configs +Manage Swarm configs Options: --help Print usage diff --git a/docs/reference/commandline/secret.md b/docs/reference/commandline/secret.md index 83c74ee638..206c9b58bd 100644 --- a/docs/reference/commandline/secret.md +++ b/docs/reference/commandline/secret.md @@ -9,7 +9,7 @@ keywords: "secret" ```markdown Usage: docker secret COMMAND -Manage Docker secrets +Manage Swarm secrets Options: --help Print usage diff --git a/docs/reference/commandline/service.md b/docs/reference/commandline/service.md index b1cff8ae44..8d834dcd90 100644 --- a/docs/reference/commandline/service.md +++ b/docs/reference/commandline/service.md @@ -9,7 +9,7 @@ keywords: "service" ```markdown Usage: docker service COMMAND -Manage services +Manage Swarm services Options: --help Print usage @@ -29,7 +29,7 @@ Run 'docker service COMMAND --help' for more information on a command. ## Description -Manage services. +Manage Swarm services. > **Note** > diff --git a/docs/reference/commandline/stack.md b/docs/reference/commandline/stack.md index c6431d247e..5003440429 100644 --- a/docs/reference/commandline/stack.md +++ b/docs/reference/commandline/stack.md @@ -9,7 +9,7 @@ keywords: "stack" ```markdown Usage: docker stack [OPTIONS] COMMAND -Manage Docker stacks +Manage Swarm stacks Options: --help Print usage