(dockerCLI command.Cli)
| 25 | } |
| 26 | |
| 27 | func 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 | |
| 51 | func runPS(ctx context.Context, dockerCli command.Cli, options psOptions) error { |
| 52 | apiClient := dockerCli.Client() |
no test coverage detected
searching dependent graphs…