feat(cmd): add --comment as alias for --reason in gt close
Add support for --comment flag as an alias for --reason in the gt close command. This provides a more intuitive option name for users who think of close messages as comments rather than reasons. Handles both --comment value and --comment=value forms. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -20,6 +21,7 @@ Examples:
|
|||||||
gt close gt-abc # Close bead gt-abc
|
gt close gt-abc # Close bead gt-abc
|
||||||
gt close gt-abc gt-def # Close multiple beads
|
gt close gt-abc gt-def # Close multiple beads
|
||||||
gt close --reason "Done" # Close with reason
|
gt close --reason "Done" # Close with reason
|
||||||
|
gt close --comment "Done" # Same as --reason (alias)
|
||||||
gt close --force # Force close pinned beads`,
|
gt close --force # Force close pinned beads`,
|
||||||
DisableFlagParsing: true, // Pass all flags through to bd close
|
DisableFlagParsing: true, // Pass all flags through to bd close
|
||||||
RunE: runClose,
|
RunE: runClose,
|
||||||
@@ -30,8 +32,20 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runClose(cmd *cobra.Command, args []string) error {
|
func runClose(cmd *cobra.Command, args []string) error {
|
||||||
|
// Convert --comment to --reason (alias support)
|
||||||
|
convertedArgs := make([]string, len(args))
|
||||||
|
for i, arg := range args {
|
||||||
|
if arg == "--comment" {
|
||||||
|
convertedArgs[i] = "--reason"
|
||||||
|
} else if strings.HasPrefix(arg, "--comment=") {
|
||||||
|
convertedArgs[i] = "--reason=" + strings.TrimPrefix(arg, "--comment=")
|
||||||
|
} else {
|
||||||
|
convertedArgs[i] = arg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Build bd close command with all args passed through
|
// Build bd close command with all args passed through
|
||||||
bdArgs := append([]string{"close"}, args...)
|
bdArgs := append([]string{"close"}, convertedArgs...)
|
||||||
bdCmd := exec.Command("bd", bdArgs...)
|
bdCmd := exec.Command("bd", bdArgs...)
|
||||||
bdCmd.Stdin = os.Stdin
|
bdCmd.Stdin = os.Stdin
|
||||||
bdCmd.Stdout = os.Stdout
|
bdCmd.Stdout = os.Stdout
|
||||||
|
|||||||
Reference in New Issue
Block a user