feat: add --all to gt crew list

This commit is contained in:
joshuavial
2026-01-09 02:22:20 +13:00
parent f4cbcb4ce9
commit 1afe3fb823
2 changed files with 52 additions and 27 deletions
+3
View File
@@ -19,6 +19,7 @@ var (
crewAccount string crewAccount string
crewAgentOverride string crewAgentOverride string
crewAll bool crewAll bool
crewListAll bool
crewDryRun bool crewDryRun bool
) )
@@ -78,6 +79,7 @@ Shows git branch, session state, and git status for each workspace.
Examples: Examples:
gt crew list # List in current rig gt crew list # List in current rig
gt crew list --rig greenplace # List in specific rig gt crew list --rig greenplace # List in specific rig
gt crew list --all # List in all rigs
gt crew list --json # JSON output`, gt crew list --json # JSON output`,
RunE: runCrewList, RunE: runCrewList,
} }
@@ -323,6 +325,7 @@ func init() {
crewAddCmd.Flags().BoolVar(&crewBranch, "branch", false, "Create a feature branch (crew/<name>)") crewAddCmd.Flags().BoolVar(&crewBranch, "branch", false, "Create a feature branch (crew/<name>)")
crewListCmd.Flags().StringVar(&crewRig, "rig", "", "Filter by rig name") crewListCmd.Flags().StringVar(&crewRig, "rig", "", "Filter by rig name")
crewListCmd.Flags().BoolVar(&crewListAll, "all", false, "List crew workspaces in all rigs")
crewListCmd.Flags().BoolVar(&crewJSON, "json", false, "Output as JSON") crewListCmd.Flags().BoolVar(&crewJSON, "json", false, "Output as JSON")
crewAtCmd.Flags().StringVar(&crewRig, "rig", "", "Rig to use") crewAtCmd.Flags().StringVar(&crewRig, "rig", "", "Rig to use")
+32 -10
View File
@@ -6,7 +6,9 @@ import (
"os" "os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/steveyegge/gastown/internal/crew"
"github.com/steveyegge/gastown/internal/git" "github.com/steveyegge/gastown/internal/git"
"github.com/steveyegge/gastown/internal/rig"
"github.com/steveyegge/gastown/internal/style" "github.com/steveyegge/gastown/internal/style"
"github.com/steveyegge/gastown/internal/tmux" "github.com/steveyegge/gastown/internal/tmux"
) )
@@ -22,32 +24,46 @@ type CrewListItem struct {
} }
func runCrewList(cmd *cobra.Command, args []string) error { func runCrewList(cmd *cobra.Command, args []string) error {
crewMgr, r, err := getCrewManager(crewRig) if crewListAll && crewRig != "" {
return fmt.Errorf("cannot use --all with --rig")
}
var rigs []*rig.Rig
if crewListAll {
allRigs, _, err := getAllRigs()
if err != nil { if err != nil {
return err return err
} }
rigs = allRigs
workers, err := crewMgr.List() } else {
_, r, err := getCrewManager(crewRig)
if err != nil { if err != nil {
return fmt.Errorf("listing crew workers: %w", err) return err
} }
rigs = []*rig.Rig{r}
if len(workers) == 0 {
fmt.Println("No crew workspaces found.")
return nil
} }
// Check session and git status for each worker // Check session and git status for each worker
t := tmux.NewTmux() t := tmux.NewTmux()
var items []CrewListItem var items []CrewListItem
for _, r := range rigs {
crewGit := git.NewGit(r.Path)
crewMgr := crew.NewManager(r, crewGit)
workers, err := crewMgr.List()
if err != nil {
fmt.Fprintf(os.Stderr, "warning: failed to list crew workers in %s: %v\n", r.Name, err)
continue
}
for _, w := range workers { for _, w := range workers {
sessionID := crewSessionName(r.Name, w.Name) sessionID := crewSessionName(r.Name, w.Name)
hasSession, _ := t.HasSession(sessionID) hasSession, _ := t.HasSession(sessionID)
crewGit := git.NewGit(w.ClonePath) workerGit := git.NewGit(w.ClonePath)
gitClean := true gitClean := true
if status, err := crewGit.Status(); err == nil { if status, err := workerGit.Status(); err == nil {
gitClean = status.Clean gitClean = status.Clean
} }
@@ -60,6 +76,12 @@ func runCrewList(cmd *cobra.Command, args []string) error {
GitClean: gitClean, GitClean: gitClean,
}) })
} }
}
if len(items) == 0 {
fmt.Println("No crew workspaces found.")
return nil
}
if crewJSON { if crewJSON {
enc := json.NewEncoder(os.Stdout) enc := json.NewEncoder(os.Stdout)