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

Function newListCommand

cli/command/network/list.go:24–46  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

22}
23
24func newListCommand(dockerCLI command.Cli) *cobra.Command {
25 options := listOptions{filter: opts.NewFilterOpt()}
26
27 cmd := &cobra.Command{
28 Use: "ls [OPTIONS]",
29 Aliases: []string{"list"},
30 Short: "List networks",
31 Args: cli.NoArgs,
32 RunE: func(cmd *cobra.Command, args []string) error {
33 return runList(cmd.Context(), dockerCLI, options)
34 },
35 ValidArgsFunction: cobra.NoFileCompletions,
36 DisableFlagsInUseLine: true,
37 }
38
39 flags := cmd.Flags()
40 flags.BoolVarP(&options.quiet, "quiet", "q", false, "Only display network IDs")
41 flags.BoolVar(&options.noTrunc, "no-trunc", false, "Do not truncate the output")
42 flags.StringVar(&options.format, "format", "", flagsHelper.FormatHelp)
43 flags.VarP(&options.filter, "filter", "f", `Provide filter values (e.g. "driver=bridge")`)
44
45 return cmd
46}
47
48func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error {
49 apiClient := dockerCLI.Client()

Callers 3

newNetworkCommandFunction · 0.70
TestNetworkListErrorsFunction · 0.70
TestNetworkListFunction · 0.70

Calls 1

runListFunction · 0.70

Tested by 2

TestNetworkListErrorsFunction · 0.56
TestNetworkListFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…