newStackCommand returns a cobra command for `stack` subcommands
(dockerCLI command.Cli)
| 16 | |
| 17 | // newStackCommand returns a cobra command for `stack` subcommands |
| 18 | func newStackCommand(dockerCLI command.Cli) *cobra.Command { |
| 19 | cmd := &cobra.Command{ |
| 20 | Use: "stack [OPTIONS]", |
| 21 | Short: "Manage Swarm stacks", |
| 22 | Args: cli.NoArgs, |
| 23 | RunE: command.ShowHelp(dockerCLI.Err()), |
| 24 | Annotations: map[string]string{ |
| 25 | "version": "1.25", |
| 26 | "swarm": "manager", |
| 27 | }, |
| 28 | DisableFlagsInUseLine: true, |
| 29 | } |
| 30 | defaultHelpFunc := cmd.HelpFunc() |
| 31 | cmd.SetHelpFunc(func(c *cobra.Command, args []string) { |
| 32 | if err := cmd.Root().PersistentPreRunE(c, args); err != nil { |
| 33 | fmt.Fprintln(dockerCLI.Err(), err) |
| 34 | return |
| 35 | } |
| 36 | defaultHelpFunc(c, args) |
| 37 | }) |
| 38 | cmd.AddCommand( |
| 39 | newDeployCommand(dockerCLI), |
| 40 | newListCommand(dockerCLI), |
| 41 | newPsCommand(dockerCLI), |
| 42 | newRemoveCommand(dockerCLI), |
| 43 | newServicesCommand(dockerCLI), |
| 44 | newConfigCommand(dockerCLI), |
| 45 | ) |
| 46 | flags := cmd.PersistentFlags() |
| 47 | flags.String("orchestrator", "", "Orchestrator to use (swarm|all)") |
| 48 | flags.SetAnnotation("orchestrator", "deprecated", nil) |
| 49 | flags.MarkDeprecated("orchestrator", "option will be ignored") |
| 50 | return cmd |
| 51 | } |
| 52 | |
| 53 | // completeNames offers completion for swarm stacks |
| 54 | func completeNames(dockerCLI completion.APIClientProvider) cobra.CompletionFunc { |
nothing calls this directly
no test coverage detected
searching dependent graphs…