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

Function newPsCommand

cli/command/stack/ps.go:27–51  ·  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 opts := psOptions{filter: cliopts.NewFilterOpt()}
29
30 cmd := &cobra.Command{
31 Use: "ps [OPTIONS] STACK",
32 Short: "List the tasks in the stack",
33 Args: cli.ExactArgs(1),
34 RunE: func(cmd *cobra.Command, args []string) error {
35 opts.namespace = args[0]
36 if err := validateStackName(opts.namespace); err != nil {
37 return err
38 }
39 return runPS(cmd.Context(), dockerCLI, opts)
40 },
41 ValidArgsFunction: completeNames(dockerCLI),
42 DisableFlagsInUseLine: true,
43 }
44 flags := cmd.Flags()
45 flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output")
46 flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names")
47 flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided")
48 flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only display task IDs")
49 flags.StringVar(&opts.format, "format", "", flagsHelper.FormatHelp)
50 return cmd
51}
52
53// runPS is the swarm implementation of docker stack ps
54func runPS(ctx context.Context, dockerCLI command.Cli, opts psOptions) error {

Callers 3

newStackCommandFunction · 0.70
TestStackPsErrorsFunction · 0.70
TestStackPsFunction · 0.70

Calls 3

validateStackNameFunction · 0.85
runPSFunction · 0.70
completeNamesFunction · 0.70

Tested by 2

TestStackPsErrorsFunction · 0.56
TestStackPsFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…