(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)
| 66 | } |
| 67 | |
| 68 | func psCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command { |
| 69 | opts := psOptions{ |
| 70 | ProjectOptions: p, |
| 71 | } |
| 72 | psCmd := &cobra.Command{ |
| 73 | Use: "ps [OPTIONS] [SERVICE...]", |
| 74 | Short: "List containers", |
| 75 | PreRunE: func(cmd *cobra.Command, args []string) error { |
| 76 | return opts.parseFilter() |
| 77 | }, |
| 78 | RunE: Adapt(func(ctx context.Context, args []string) error { |
| 79 | return runPs(ctx, dockerCli, backendOptions, args, opts) |
| 80 | }), |
| 81 | ValidArgsFunction: completeServiceNames(dockerCli, p), |
| 82 | } |
| 83 | flags := psCmd.Flags() |
| 84 | flags.StringVar(&opts.Format, "format", "table", cliflags.FormatHelp) |
| 85 | flags.StringVar(&opts.Filter, "filter", "", "Filter services by a property (supported filters: status)") |
| 86 | flags.StringArrayVar(&opts.Status, "status", []string{}, "Filter services by status. Values: [paused | restarting | removing | running | dead | created | exited]") |
| 87 | flags.BoolVarP(&opts.Quiet, "quiet", "q", false, "Only display IDs") |
| 88 | flags.BoolVar(&opts.Services, "services", false, "Display services") |
| 89 | flags.BoolVar(&opts.Orphans, "orphans", true, "Include orphaned services (not declared by project)") |
| 90 | flags.BoolVarP(&opts.All, "all", "a", false, "Show all stopped containers (including those created by the run command)") |
| 91 | flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Don't truncate output") |
| 92 | return psCmd |
| 93 | } |
| 94 | |
| 95 | func runPs(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, services []string, opts psOptions) error { //nolint:gocyclo |
| 96 | project, name, err := opts.projectOrName(ctx, dockerCli, services...) |
no test coverage detected