MCPcopy Index your code
hub / github.com/docker/cli / newStackCommand

Function newStackCommand

cli/command/stack/cmd.go:18–51  ·  view source on GitHub ↗

newStackCommand returns a cobra command for `stack` subcommands

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

16
17// newStackCommand returns a cobra command for `stack` subcommands
18func 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
54func completeNames(dockerCLI completion.APIClientProvider) cobra.CompletionFunc {

Callers

nothing calls this directly

Calls 8

newDeployCommandFunction · 0.85
newServicesCommandFunction · 0.85
newListCommandFunction · 0.70
newPsCommandFunction · 0.70
newRemoveCommandFunction · 0.70
newConfigCommandFunction · 0.70
ErrMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…