2016-09-08 13:11:39 -04:00
|
|
|
package stack
|
|
|
|
|
|
|
|
import (
|
2018-04-25 08:24:46 -04:00
|
|
|
"fmt"
|
|
|
|
|
2017-04-17 18:07:56 -04:00
|
|
|
"github.com/docker/cli/cli"
|
|
|
|
"github.com/docker/cli/cli/command"
|
2016-09-08 13:11:39 -04:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2016-10-06 10:09:54 -04:00
|
|
|
// NewStackCommand returns a cobra command for `stack` subcommands
|
2017-10-11 12:18:27 -04:00
|
|
|
func NewStackCommand(dockerCli command.Cli) *cobra.Command {
|
2016-10-06 10:09:54 -04:00
|
|
|
cmd := &cobra.Command{
|
2018-06-22 02:16:27 -04:00
|
|
|
Use: "stack [OPTIONS]",
|
2018-01-11 17:42:50 -05:00
|
|
|
Short: "Manage Docker stacks",
|
|
|
|
Args: cli.NoArgs,
|
2022-02-22 07:46:35 -05:00
|
|
|
RunE: command.ShowHelp(dockerCli.Err()),
|
2018-01-11 17:42:50 -05:00
|
|
|
Annotations: map[string]string{
|
2018-06-20 08:48:50 -04:00
|
|
|
"version": "1.25",
|
2018-01-11 17:42:50 -05:00
|
|
|
},
|
2016-10-06 10:09:54 -04:00
|
|
|
}
|
2018-06-20 08:48:50 -04:00
|
|
|
defaultHelpFunc := cmd.HelpFunc()
|
2018-07-31 19:48:27 -04:00
|
|
|
cmd.SetHelpFunc(func(c *cobra.Command, args []string) {
|
2019-03-06 09:01:12 -05:00
|
|
|
if err := cmd.Root().PersistentPreRunE(c, args); err != nil {
|
|
|
|
fmt.Fprintln(dockerCli.Err(), err)
|
|
|
|
return
|
|
|
|
}
|
2018-07-31 19:48:27 -04:00
|
|
|
defaultHelpFunc(c, args)
|
2018-06-20 08:48:50 -04:00
|
|
|
})
|
2017-12-04 06:30:39 -05:00
|
|
|
cmd.AddCommand(
|
2022-02-22 07:46:35 -05:00
|
|
|
newDeployCommand(dockerCli),
|
|
|
|
newListCommand(dockerCli),
|
|
|
|
newPsCommand(dockerCli),
|
|
|
|
newRemoveCommand(dockerCli),
|
|
|
|
newServicesCommand(dockerCli),
|
2017-12-04 06:30:39 -05:00
|
|
|
)
|
|
|
|
flags := cmd.PersistentFlags()
|
2021-06-16 03:08:42 -04:00
|
|
|
flags.String("orchestrator", "", "Orchestrator to use (swarm|all)")
|
2021-06-29 08:48:14 -04:00
|
|
|
flags.SetAnnotation("orchestrator", "deprecated", nil)
|
2022-02-22 07:46:35 -05:00
|
|
|
flags.MarkDeprecated("orchestrator", "option will be ignored")
|
2016-10-06 10:09:54 -04:00
|
|
|
return cmd
|
2016-09-08 13:11:39 -04:00
|
|
|
}
|