(dockerCLI command.Cli)
| 21 | } |
| 22 | |
| 23 | func newListCommand(dockerCLI command.Cli) *cobra.Command { |
| 24 | options := listOptions{filter: opts.NewFilterOpt()} |
| 25 | |
| 26 | cmd := &cobra.Command{ |
| 27 | Use: "ls [OPTIONS]", |
| 28 | Aliases: []string{"list"}, |
| 29 | Short: "List nodes in the swarm", |
| 30 | Args: cli.NoArgs, |
| 31 | RunE: func(cmd *cobra.Command, args []string) error { |
| 32 | return runList(cmd.Context(), dockerCLI, options) |
| 33 | }, |
| 34 | ValidArgsFunction: cobra.NoFileCompletions, |
| 35 | DisableFlagsInUseLine: true, |
| 36 | } |
| 37 | flags := cmd.Flags() |
| 38 | flags.BoolVarP(&options.quiet, "quiet", "q", false, "Only display IDs") |
| 39 | flags.StringVar(&options.format, "format", "", flagsHelper.FormatHelp) |
| 40 | flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided") |
| 41 | |
| 42 | return cmd |
| 43 | } |
| 44 | |
| 45 | func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error { |
| 46 | apiClient := dockerCLI.Client() |
searching dependent graphs…