diff --git a/internal/cmd/show.go b/internal/cmd/show.go new file mode 100644 index 00000000..80367b6a --- /dev/null +++ b/internal/cmd/show.go @@ -0,0 +1,57 @@ +package cmd + +import ( + "fmt" + "os" + "os/exec" + "syscall" + + "github.com/spf13/cobra" +) + +func init() { + showCmd.GroupID = GroupWork + rootCmd.AddCommand(showCmd) +} + +var showCmd = &cobra.Command{ + Use: "show [flags]", + Short: "Show details of a bead", + Long: `Displays the full details of a bead by ID. + +Delegates to 'bd show' - all bd show flags are supported. +Works with any bead prefix (gt-, bd-, hq-, etc.) and routes +to the correct beads database automatically. + +Examples: + gt show gt-abc123 # Show a gastown issue + gt show hq-xyz789 # Show a town-level bead (convoy, mail, etc.) + gt show bd-def456 # Show a beads issue + gt show gt-abc123 --json # Output as JSON + gt show gt-abc123 -v # Verbose output`, + DisableFlagParsing: true, // Pass all flags through to bd show + RunE: runShow, +} + +func runShow(cmd *cobra.Command, args []string) error { + if len(args) == 0 { + return fmt.Errorf("bead ID required\n\nUsage: gt show [flags]") + } + + return execBdShow(args) +} + +// execBdShow replaces the current process with 'bd show'. +func execBdShow(args []string) error { + bdPath, err := exec.LookPath("bd") + if err != nil { + return fmt.Errorf("bd not found in PATH: %w", err) + } + + // Build args: bd show + // argv[0] must be the program name for exec + fullArgs := append([]string{"bd", "show"}, args...) + + // Replace process with bd show + return syscall.Exec(bdPath, fullArgs, os.Environ()) +}