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

Function newPsCommand

cli/command/node/ps.go:25–52  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

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

Callers 3

newNodeCommandFunction · 0.70
TestNodePsErrorsFunction · 0.70
TestNodePsFunction · 0.70

Calls 2

completeNodeNamesFunction · 0.85
runPsFunction · 0.70

Tested by 2

TestNodePsErrorsFunction · 0.56
TestNodePsFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…