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

Function newListCommand

cli/command/node/list.go:23–43  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

21}
22
23func 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
45func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error {
46 apiClient := dockerCLI.Client()

Callers 6

newNodeCommandFunction · 0.70
TestNodeListFunction · 0.70
TestNodeListFormatFunction · 0.70

Calls 1

runListFunction · 0.70

Tested by 5

TestNodeListFunction · 0.56
TestNodeListFormatFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…