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

Function newPruneCommand

cli/command/system/prune.go:33–57  ·  view source on GitHub ↗

newPruneCommand creates a new cobra.Command for `docker prune`

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

31
32// newPruneCommand creates a new cobra.Command for `docker prune`
33func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
34 options := pruneOptions{filter: opts.NewFilterOpt()}
35
36 cmd := &cobra.Command{
37 Use: "prune [OPTIONS]",
38 Short: "Remove unused data",
39 Args: cli.NoArgs,
40 RunE: func(cmd *cobra.Command, args []string) error {
41 return runPrune(cmd.Context(), dockerCLI, options)
42 },
43 Annotations: map[string]string{"version": "1.25"},
44 ValidArgsFunction: cobra.NoFileCompletions,
45 DisableFlagsInUseLine: true,
46 }
47
48 flags := cmd.Flags()
49 flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation")
50 flags.BoolVarP(&options.all, "all", "a", false, "Remove all unused images not just dangling ones")
51 flags.BoolVar(&options.pruneVolumes, "volumes", false, "Prune anonymous volumes")
52 flags.Var(&options.filter, "filter", `Provide filter values (e.g. "label=<key>=<value>")`)
53 // "filter" flag is available in 1.28 (docker 17.04) and up
54 flags.SetAnnotation("filter", "version", []string{"1.28"})
55
56 return cmd
57}
58
59const confirmationTemplate = `WARNING! This will remove:
60{{- range $_, $warning := .warnings }}

Callers 3

TestPrunePromptFiltersFunction · 0.70
newSystemCommandFunction · 0.70

Calls 1

runPruneFunction · 0.70

Tested by 2

TestPrunePromptFiltersFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…