Add mol-polecat-work, mol-polecat-lease, mol-gastown-boot formulas; fix spawn.go to use catalog ID

This commit is contained in:
Steve Yegge
2025-12-25 11:46:58 -08:00
parent 7a9d8104b0
commit 9446cd4806
6 changed files with 1803 additions and 1419 deletions

View File

@@ -0,0 +1,79 @@
package cmd
import (
"fmt"
"os/exec"
"sort"
"github.com/spf13/cobra"
)
// cycleCrewSession switches to the next or previous crew session in the same rig.
// direction: 1 for next, -1 for previous
func cycleCrewSession(direction int) error {
// Get current session
currentSession := getCurrentTmuxSession()
if currentSession == "" {
return fmt.Errorf("not in a tmux session")
}
// Parse rig name from current session
rigName, _, ok := parseCrewSessionName(currentSession)
if !ok {
return fmt.Errorf("not in a crew session (expected gt-<rig>-crew-<name>)")
}
// Find all crew sessions for this rig
sessions, err := findRigCrewSessions(rigName)
if err != nil {
return fmt.Errorf("listing sessions: %w", err)
}
if len(sessions) == 0 {
return fmt.Errorf("no crew sessions found for rig %s", rigName)
}
// Sort for consistent ordering
sort.Strings(sessions)
// Find current position
currentIdx := -1
for i, s := range sessions {
if s == currentSession {
currentIdx = i
break
}
}
if currentIdx == -1 {
// Current session not in list (shouldn't happen)
return fmt.Errorf("current session not found in crew list")
}
// Calculate target index (with wrapping)
targetIdx := (currentIdx + direction + len(sessions)) % len(sessions)
if targetIdx == currentIdx {
// Only one session, nothing to switch to
fmt.Printf("Only one crew session in rig %s\n", rigName)
return nil
}
targetSession := sessions[targetIdx]
// Switch to target session
cmd := exec.Command("tmux", "switch-client", "-t", targetSession)
if err := cmd.Run(); err != nil {
return fmt.Errorf("switching to %s: %w", targetSession, err)
}
return nil
}
func runCrewNext(cmd *cobra.Command, args []string) error {
return cycleCrewSession(1)
}
func runCrewPrev(cmd *cobra.Command, args []string) error {
return cycleCrewSession(-1)
}