MCPcopy Create free account
hub / github.com/docker/cli / newListCommand

Function newListCommand

cli/command/service/list.go:21–42  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

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

Callers 3

newServiceCommandFunction · 0.70
TestServiceListOrderFunction · 0.70

Calls 1

runListFunction · 0.70

Tested by 2

TestServiceListOrderFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…