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

Function newPruneCommand

cli/command/container/prune.go:32–60  ·  view source on GitHub ↗

newPruneCommand returns a new cobra prune command for containers.

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

30
31// newPruneCommand returns a new cobra prune command for containers.
32func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
33 options := pruneOptions{filter: opts.NewFilterOpt()}
34
35 cmd := &cobra.Command{
36 Use: "prune [OPTIONS]",
37 Short: "Remove all stopped containers",
38 Args: cli.NoArgs,
39 RunE: func(cmd *cobra.Command, args []string) error {
40 spaceReclaimed, output, err := runPrune(cmd.Context(), dockerCLI, options)
41 if err != nil {
42 return err
43 }
44 if output != "" {
45 fmt.Fprintln(dockerCLI.Out(), output)
46 }
47 fmt.Fprintln(dockerCLI.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
48 return nil
49 },
50 Annotations: map[string]string{"version": "1.25"},
51 ValidArgsFunction: cobra.NoFileCompletions,
52 DisableFlagsInUseLine: true,
53 }
54
55 flags := cmd.Flags()
56 flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation")
57 flags.Var(&options.filter, "filter", `Provide filter values (e.g. "until=<timestamp>")`)
58
59 return cmd
60}
61
62const warning = `WARNING! This will remove all stopped containers.
63Are you sure you want to continue?`

Callers 2

newContainerCommandFunction · 0.70

Calls 2

runPruneFunction · 0.70
OutMethod · 0.65

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…