diff --git a/workspaces.py b/workspaces.py index 3d9bdd8..d8ae44a 100755 --- a/workspaces.py +++ b/workspaces.py @@ -387,6 +387,7 @@ def list_workspaces( @app.command("create") +@app.command("new", hidden=True) def create_workspace( ctx: typer.Context, name: Optional[str] = typer.Option( @@ -515,6 +516,7 @@ def pick_repo_with_iterfzf(repos: List[Path]) -> Optional[Path]: @app.command("add-repo") +@app.command("add", hidden=True) def add_repo( ctx: typer.Context, workspace: Optional[str] = typer.Option( @@ -1015,5 +1017,75 @@ def push_workspace( ) +# ---------------- status (current workspace) ---------------- + + +@app.command("status") +def status_workspace( + ctx: typer.Context, + workspace: Optional[str] = typer.Option( + None, + "--workspace", + "-w", + help=( + "Workspace directory name to show status for. " + "If omitted, uses the workspace containing the current directory." + ), + ), +): + """ + Show detailed status for the current (or specified) workspace. + + For each repo in the workspace: + - repo directory name + - branch + - ahead/behind/dirty indicator + - number of changed files + """ + _settings, _repos_dir, workspaces_dir = get_ctx_paths(ctx) + ws_dir = find_workspace_dir(workspaces_dir, workspace) + if not ws_dir.exists(): + console.print(f"[red]Workspace '{ws_dir.name}' does not exist at {ws_dir}[/red]") + raise typer.Exit(1) + + title, desc = read_workspace_readme(ws_dir) + + table = Table( + title=f"Status for workspace '{title}' (dir: {ws_dir.name})", + show_lines=False, + ) + table.add_column("Repo (dir)", style="bold") + table.add_column("Branch") + table.add_column("Ahead/Behind/Dirty") + table.add_column("Changed Files", justify="right") + + worktrees: List[Path] = [] + for child in sorted(p for p in ws_dir.iterdir() if p.is_dir()): + if child.name.lower() == "readme.md": + continue + if not ensure_git_repo(child): + continue + worktrees.append(child) + + if not worktrees: + console.print(f"[yellow]No repos in workspace {ws_dir.name}[/yellow]") + raise typer.Exit(0) + + for wt in worktrees: + branch = get_current_branch(wt) or "?" + status = get_git_status(wt) + changes = git_status_porcelain(wt) + table.add_row( + wt.name, + branch, + status.indicator, + str(len(changes)), + ) + + console.print(table) + + if desc: + console.print(Panel(desc, title="Workspace description")) + if __name__ == "__main__": app()