Show workflow run status.
(
run_id: str | None = typer.Argument(None, help="Run ID to inspect (shows all if omitted)"),
json_output: bool = typer.Option(
False,
"--json",
help="Emit run status as a single JSON object instead of formatted text.",
),
)
| 444 | |
| 445 | @workflow_app.command("status") |
| 446 | def workflow_status( |
| 447 | run_id: str | None = typer.Argument(None, help="Run ID to inspect (shows all if omitted)"), |
| 448 | json_output: bool = typer.Option( |
| 449 | False, |
| 450 | "--json", |
| 451 | help="Emit run status as a single JSON object instead of formatted text.", |
| 452 | ), |
| 453 | ): |
| 454 | """Show workflow run status.""" |
| 455 | from .engine import WorkflowEngine |
| 456 | |
| 457 | project_root = _require_specify_project() |
| 458 | engine = WorkflowEngine(project_root) |
| 459 | |
| 460 | if run_id: |
| 461 | try: |
| 462 | from .engine import RunState |
| 463 | state = RunState.load(run_id, project_root) |
| 464 | except FileNotFoundError: |
| 465 | console.print(f"[red]Error:[/red] Run not found: {run_id}") |
| 466 | raise typer.Exit(1) |
| 467 | |
| 468 | if json_output: |
| 469 | # Build on the shared run/resume payload so the common fields |
| 470 | # (including current_step_index) stay identical across commands. |
| 471 | payload = { |
| 472 | **_workflow_run_payload(state), |
| 473 | "created_at": state.created_at, |
| 474 | "updated_at": state.updated_at, |
| 475 | "steps": { |
| 476 | sid: sd.get("status", "unknown") |
| 477 | for sid, sd in state.step_results.items() |
| 478 | }, |
| 479 | } |
| 480 | _emit_workflow_json(payload) |
| 481 | return |
| 482 | |
| 483 | status_colors = { |
| 484 | "completed": "green", |
| 485 | "paused": "yellow", |
| 486 | "failed": "red", |
| 487 | "aborted": "red", |
| 488 | "running": "blue", |
| 489 | "created": "dim", |
| 490 | } |
| 491 | color = status_colors.get(state.status.value, "white") |
| 492 | |
| 493 | console.print(f"\n[bold cyan]Workflow Run: {state.run_id}[/bold cyan]") |
| 494 | console.print(f" Workflow: {state.workflow_id}") |
| 495 | console.print(f" Status: [{color}]{state.status.value}[/{color}]") |
| 496 | console.print(f" Created: {state.created_at}") |
| 497 | console.print(f" Updated: {state.updated_at}") |
| 498 | |
| 499 | if state.current_step_id: |
| 500 | console.print(f" Current: {state.current_step_id}") |
| 501 | |
| 502 | if state.step_results: |
| 503 | console.print(f"\n [bold]Steps ({len(state.step_results)}):[/bold]") |
nothing calls this directly
no test coverage detected