feat: add --all to gt crew list
This commit is contained in:
@@ -19,6 +19,7 @@ var (
|
|||||||
crewAccount string
|
crewAccount string
|
||||||
crewAgentOverride string
|
crewAgentOverride string
|
||||||
crewAll bool
|
crewAll bool
|
||||||
|
crewListAll bool
|
||||||
crewDryRun bool
|
crewDryRun bool
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -77,7 +78,8 @@ 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")
|
||||||
|
|||||||
@@ -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,43 +24,63 @@ 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 != "" {
|
||||||
if err != nil {
|
return fmt.Errorf("cannot use --all with --rig")
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
workers, err := crewMgr.List()
|
var rigs []*rig.Rig
|
||||||
if err != nil {
|
if crewListAll {
|
||||||
return fmt.Errorf("listing crew workers: %w", err)
|
allRigs, _, err := getAllRigs()
|
||||||
}
|
if err != nil {
|
||||||
|
return err
|
||||||
if len(workers) == 0 {
|
}
|
||||||
fmt.Println("No crew workspaces found.")
|
rigs = allRigs
|
||||||
return nil
|
} else {
|
||||||
|
_, r, err := getCrewManager(crewRig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rigs = []*rig.Rig{r}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 _, w := range workers {
|
for _, r := range rigs {
|
||||||
sessionID := crewSessionName(r.Name, w.Name)
|
crewGit := git.NewGit(r.Path)
|
||||||
hasSession, _ := t.HasSession(sessionID)
|
crewMgr := crew.NewManager(r, crewGit)
|
||||||
|
|
||||||
crewGit := git.NewGit(w.ClonePath)
|
workers, err := crewMgr.List()
|
||||||
gitClean := true
|
if err != nil {
|
||||||
if status, err := crewGit.Status(); err == nil {
|
fmt.Fprintf(os.Stderr, "warning: failed to list crew workers in %s: %v\n", r.Name, err)
|
||||||
gitClean = status.Clean
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
items = append(items, CrewListItem{
|
for _, w := range workers {
|
||||||
Name: w.Name,
|
sessionID := crewSessionName(r.Name, w.Name)
|
||||||
Rig: r.Name,
|
hasSession, _ := t.HasSession(sessionID)
|
||||||
Branch: w.Branch,
|
|
||||||
Path: w.ClonePath,
|
workerGit := git.NewGit(w.ClonePath)
|
||||||
HasSession: hasSession,
|
gitClean := true
|
||||||
GitClean: gitClean,
|
if status, err := workerGit.Status(); err == nil {
|
||||||
})
|
gitClean = status.Clean
|
||||||
|
}
|
||||||
|
|
||||||
|
items = append(items, CrewListItem{
|
||||||
|
Name: w.Name,
|
||||||
|
Rig: r.Name,
|
||||||
|
Branch: w.Branch,
|
||||||
|
Path: w.ClonePath,
|
||||||
|
HasSession: hasSession,
|
||||||
|
GitClean: gitClean,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(items) == 0 {
|
||||||
|
fmt.Println("No crew workspaces found.")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if crewJSON {
|
if crewJSON {
|
||||||
|
|||||||
Reference in New Issue
Block a user