Adds shell integration for automatic Gas Town context detection. Features: - `gt enable` / `gt disable` - Global on/off switch - `gt shell install|remove|status` - Shell integration management - `gt rig quick-add [path]` - One-command project setup - `gt uninstall` - Clean removal with options - Shell hook auto-sets GT_TOWN_ROOT/GT_RIG on cd Implementation: - XDG-compliant state storage (~/.local/state/gastown/) - Safe RC file manipulation with block markers - Environment overrides (GASTOWN_DISABLED/ENABLED) - Doctor check for global state validation Co-authored-by: Sohail Mohammad <sohailm25@gmail.com>
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
// ABOUTME: Command to enable Gas Town system-wide.
|
|
// ABOUTME: Sets the global state to enabled for all agentic coding tools.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/steveyegge/gastown/internal/state"
|
|
"github.com/steveyegge/gastown/internal/style"
|
|
)
|
|
|
|
var enableCmd = &cobra.Command{
|
|
Use: "enable",
|
|
GroupID: GroupConfig,
|
|
Short: "Enable Gas Town system-wide",
|
|
Long: `Enable Gas Town for all agentic coding tools.
|
|
|
|
When enabled:
|
|
- Shell hooks set GT_TOWN_ROOT and GT_RIG environment variables
|
|
- Claude Code SessionStart hooks run 'gt prime' for context
|
|
- Git repos are auto-registered as rigs (configurable)
|
|
|
|
Use 'gt disable' to turn off. Use 'gt status --global' to check state.
|
|
|
|
Environment overrides:
|
|
GASTOWN_DISABLED=1 - Disable for current session only
|
|
GASTOWN_ENABLED=1 - Enable for current session only`,
|
|
RunE: runEnable,
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(enableCmd)
|
|
}
|
|
|
|
func runEnable(cmd *cobra.Command, args []string) error {
|
|
if err := state.Enable(Version); err != nil {
|
|
return fmt.Errorf("enabling Gas Town: %w", err)
|
|
}
|
|
|
|
fmt.Printf("%s Gas Town enabled\n", style.Success.Render("✓"))
|
|
fmt.Println()
|
|
fmt.Println("Gas Town will now:")
|
|
fmt.Println(" • Inject context into Claude Code sessions")
|
|
fmt.Println(" • Set GT_TOWN_ROOT and GT_RIG environment variables")
|
|
fmt.Println(" • Auto-register git repos as rigs (if configured)")
|
|
fmt.Println()
|
|
fmt.Printf("Use %s to disable, %s to check status\n",
|
|
style.Dim.Render("gt disable"),
|
|
style.Dim.Render("gt status --global"))
|
|
|
|
return nil
|
|
}
|