(dockerCLI command.Cli)
| 26 | } |
| 27 | |
| 28 | func 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 | |
| 54 | func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error { |
| 55 | apiClient := dockerCLI.Client() |
searching dependent graphs…