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

Function newPsCommand

cli/command/service/ps.go:27–49  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

25}
26
27func newPsCommand(dockerCLI command.Cli) *cobra.Command {
28 options := psOptions{filter: opts.NewFilterOpt()}
29
30 cmd := &cobra.Command{
31 Use: "ps [OPTIONS] SERVICE [SERVICE...]",
32 Short: "List the tasks of one or more services",
33 Args: cli.RequiresMinArgs(1),
34 RunE: func(cmd *cobra.Command, args []string) error {
35 options.services = args
36 return runPS(cmd.Context(), dockerCLI, options)
37 },
38 ValidArgsFunction: completeServiceNames(dockerCLI),
39 DisableFlagsInUseLine: true,
40 }
41 flags := cmd.Flags()
42 flags.BoolVarP(&options.quiet, "quiet", "q", false, "Only display task IDs")
43 flags.BoolVar(&options.noTrunc, "no-trunc", false, "Do not truncate output")
44 flags.BoolVar(&options.noResolve, "no-resolve", false, "Do not map IDs to Names")
45 flags.StringVar(&options.format, "format", "", "Pretty-print tasks using a Go template")
46 flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided")
47
48 return cmd
49}
50
51func runPS(ctx context.Context, dockerCli command.Cli, options psOptions) error {
52 apiClient := dockerCli.Client()

Callers 1

newServiceCommandFunction · 0.70

Calls 2

completeServiceNamesFunction · 0.85
runPSFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…