(dockerCLI command.Cli)
| 21 | } |
| 22 | |
| 23 | func newRemoveCommand(dockerCLI command.Cli) *cobra.Command { |
| 24 | var opts removeOptions |
| 25 | |
| 26 | cmd := &cobra.Command{ |
| 27 | Use: "rm [OPTIONS] STACK [STACK...]", |
| 28 | Aliases: []string{"remove", "down"}, |
| 29 | Short: "Remove one or more stacks", |
| 30 | Args: cli.RequiresMinArgs(1), |
| 31 | RunE: func(cmd *cobra.Command, args []string) error { |
| 32 | opts.namespaces = args |
| 33 | if err := validateStackNames(opts.namespaces); err != nil { |
| 34 | return err |
| 35 | } |
| 36 | return runRemove(cmd.Context(), dockerCLI, opts) |
| 37 | }, |
| 38 | ValidArgsFunction: completeNames(dockerCLI), |
| 39 | DisableFlagsInUseLine: true, |
| 40 | } |
| 41 | |
| 42 | flags := cmd.Flags() |
| 43 | flags.BoolVarP(&opts.detach, "detach", "d", true, "Do not wait for stack removal") |
| 44 | return cmd |
| 45 | } |
| 46 | |
| 47 | // runRemove is the swarm implementation of docker stack remove. |
| 48 | func runRemove(ctx context.Context, dockerCli command.Cli, opts removeOptions) error { |
searching dependent graphs…