Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions contree_cli/cli/ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PsArgs(ArgumentsProtocol):
quiet: bool = False
all: bool = False
show_max: int | None = None
status: str = "EXECUTING"
status: str | None = None
kind: str | None = None
since: datetime | None = None
until: datetime | None = None
Expand Down Expand Up @@ -82,8 +82,8 @@ def setup_parser(p: argparse.ArgumentParser) -> SetupResult:
p.add_argument(
*FLAGS["status"],
choices=tuple(itertools.chain.from_iterable(STATUS_CHOICES.items())),
default="EXECUTING",
help="Filter by status",
default=None,
help="Filter by status (default: EXECUTING only, unless -a is used)",
)
Comment thread
mosquito marked this conversation as resolved.
p.add_argument(
*FLAGS["kind"],
Expand Down Expand Up @@ -174,11 +174,13 @@ def cmd_ps(args: PsArgs) -> None:
formatter: OutputFormatter = FORMATTER.get()

status: str | None = None
if not args.all:
if args.status is not None:
if len(args.status) == 1:
status = STATUS_CHOICES.get(args.status, args.status)
else:
status = args.status
elif not args.all:
status = "EXECUTING"

since: str | None = None
if args.since is not None:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ def test_all_flag_no_status_param(self, contree_client):
_run_cmd(contree_client, ops, all=True)
assert "status=" not in contree_client.request_paths[0]

def test_all_with_explicit_status(self, contree_client, capsys):
"""--all combined with --status sends the status filter."""
ops = [_make_op(0, status="FAILED")]
_run_cmd(contree_client, ops, all=True, status="FAILED")
assert "status=FAILED" in contree_client.request_paths[0]
assert "op-0" in capsys.readouterr().out

@pytest.mark.parametrize(
"short,full",
list(STATUS_CHOICES.items()),
Expand Down
Loading