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

Function newListCommand

cli/command/volume/list.go:28–52  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

26}
27
28func newListCommand(dockerCLI command.Cli) *cobra.Command {
29 options := listOptions{filter: opts.NewFilterOpt()}
30
31 cmd := &cobra.Command{
32 Use: "ls [OPTIONS]",
33 Aliases: []string{"list"},
34 Short: "List volumes",
35 Args: cli.NoArgs,
36 RunE: func(cmd *cobra.Command, args []string) error {
37 return runList(cmd.Context(), dockerCLI, options)
38 },
39 ValidArgsFunction: cobra.NoFileCompletions,
40 DisableFlagsInUseLine: true,
41 }
42
43 flags := cmd.Flags()
44 flags.BoolVarP(&options.quiet, "quiet", "q", false, "Only display volume names")
45 flags.StringVar(&options.format, "format", "", flagsHelper.FormatHelp)
46 flags.VarP(&options.filter, "filter", "f", `Provide filter values (e.g. "dangling=true")`)
47 flags.BoolVar(&options.cluster, "cluster", false, "Display only cluster volumes, and use cluster volume list formatting")
48 _ = flags.SetAnnotation("cluster", "version", []string{"1.42"})
49 _ = flags.SetAnnotation("cluster", "swarm", []string{"manager"})
50
51 return cmd
52}
53
54func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error {
55 apiClient := dockerCLI.Client()

Callers 7

newVolumeCommandFunction · 0.70
TestVolumeListErrorsFunction · 0.70
TestVolumeListWithFormatFunction · 0.70
TestVolumeListSortOrderFunction · 0.70
TestClusterVolumeListFunction · 0.70

Calls 1

runListFunction · 0.70

Tested by 6

TestVolumeListErrorsFunction · 0.56
TestVolumeListWithFormatFunction · 0.56
TestVolumeListSortOrderFunction · 0.56
TestClusterVolumeListFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…