Skip to content

Commit 75f76fd

Browse files
committed
Refactor status command to use a table argument for customizable output
1 parent 2ba18ed commit 75f76fd

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

cluv/__main__.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,15 @@ def add_submit_args(
139139
def add_status_args(subparsers: Subparsers) -> argparse.ArgumentParser:
140140
status_parser = subparsers.add_parser(
141141
"status",
142-
help="Get the status of available clusters.",
142+
help="Get the status of clusters and jobs.",
143143
formatter_class=rich_argparse.RichHelpFormatter,
144144
)
145145
status_parser.add_argument(
146-
"clusters",
147-
nargs="*",
148-
default=None,
149-
metavar="<cluster>",
150-
help=("Cluster(s) to query. Leave empty to query all clusters with an active connection."),
151-
)
152-
status_parser.add_argument(
153-
"--show",
146+
"table",
147+
nargs="?",
154148
choices=["clusters", "jobs", "all"],
155149
default="all",
150+
metavar="<table>",
156151
help="Which table to display: cluster overview, jobs overview, or both (default: all).",
157152
)
158153
status_parser.set_defaults(func=status)

cluv/cli/status.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,12 +522,13 @@ def _build_legend() -> Panel:
522522
return Panel(legend, title="Legend", border_style="dim", padding=(0, 1))
523523

524524

525-
async def status(clusters: list[str] | None = None, show: str = "all"):
525+
async def status(table: str) -> None:
526526
"""Gets the status of available clusters.
527527
- Gives you an overview of the state of each cluster, and displays an overview of the state of your jobs across the clusters.
528528
- Displays the number of idle nodes, or the number of idle GPUs, or something similar, for each cluster
529529
"""
530530
console = Console()
531+
clusters = get_config().clusters_names
531532
clusters = list(clusters or [])
532533

533534
if clusters:
@@ -559,10 +560,10 @@ async def status(clusters: list[str] | None = None, show: str = "all"):
559560
console.rule(f"[bold cyan]cluv status[/bold cyan] {label}")
560561
console.print()
561562

562-
if show in ("clusters", "all"):
563+
if table in ("clusters", "all"):
563564
console.print(_build_cluster_table(data))
564565
console.print(_build_legend())
565566
console.print()
566-
if show in ("jobs", "all"):
567+
if table in ("jobs", "all"):
567568
console.print(_build_my_jobs_table(data))
568569
console.print()

0 commit comments

Comments
 (0)