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

Function newPruneCommand

cli/command/network/prune.go:31–57  ·  view source on GitHub ↗

newPruneCommand returns a new cobra prune command for networks

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

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

Callers 2

newNetworkCommandFunction · 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…