(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)
| 36 | } |
| 37 | |
| 38 | func removeCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command { |
| 39 | opts := removeOptions{ |
| 40 | ProjectOptions: p, |
| 41 | } |
| 42 | cmd := &cobra.Command{ |
| 43 | Use: "rm [OPTIONS] [SERVICE...]", |
| 44 | Short: "Removes stopped service containers", |
| 45 | Long: `Removes stopped service containers |
| 46 | |
| 47 | By default, anonymous volumes attached to containers will not be removed. You |
| 48 | can override this with -v. To list all volumes, use "docker volume ls". |
| 49 | |
| 50 | Any data which is not in a volume will be lost.`, |
| 51 | RunE: Adapt(func(ctx context.Context, args []string) error { |
| 52 | return runRemove(ctx, dockerCli, backendOptions, opts, args) |
| 53 | }), |
| 54 | ValidArgsFunction: completeServiceNames(dockerCli, p), |
| 55 | } |
| 56 | f := cmd.Flags() |
| 57 | f.BoolVarP(&opts.force, "force", "f", false, "Don't ask to confirm removal") |
| 58 | f.BoolVarP(&opts.stop, "stop", "s", false, "Stop the containers, if required, before removing") |
| 59 | f.BoolVarP(&opts.volumes, "volumes", "v", false, "Remove any anonymous volumes attached to containers") |
| 60 | f.BoolP("all", "a", false, "Deprecated - no effect") |
| 61 | f.MarkHidden("all") //nolint:errcheck |
| 62 | |
| 63 | return cmd |
| 64 | } |
| 65 | |
| 66 | func runRemove(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts removeOptions, services []string) error { |
| 67 | project, name, err := opts.projectOrName(ctx, dockerCli, services...) |
no test coverage detected