feat: Add --body flag as alias for --description
Adds --body as a hidden alias for --description in create/update commands, following GitHub CLI convention for better agent ergonomics. The --body flag: - Works alongside existing --description and -d flags - Hidden from help output to avoid clutter - Validates conflicts when both flags used with different values - Available in both 'bd create' and 'bd update' commands 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -77,7 +77,7 @@ var createCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
// Get field values, preferring explicit flags over template defaults
|
||||
description, _ := cmd.Flags().GetString("description")
|
||||
description, _ := getDescriptionFlag(cmd)
|
||||
if description == "" && tmpl != nil {
|
||||
description = tmpl.Description
|
||||
}
|
||||
|
||||
@@ -1,16 +1,51 @@
|
||||
package main
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// registerCommonIssueFlags registers flags common to create and update commands.
|
||||
func registerCommonIssueFlags(cmd *cobra.Command) {
|
||||
cmd.Flags().StringP("assignee", "a", "", "Assignee")
|
||||
cmd.Flags().StringP("description", "d", "", "Issue description")
|
||||
cmd.Flags().String("body", "", "Alias for --description (GitHub CLI convention)")
|
||||
_ = cmd.Flags().MarkHidden("body") // Hidden alias for agent/CLI ergonomics
|
||||
cmd.Flags().String("design", "", "Design notes")
|
||||
cmd.Flags().String("acceptance", "", "Acceptance criteria")
|
||||
cmd.Flags().String("external-ref", "", "External reference (e.g., 'gh-9', 'jira-ABC')")
|
||||
}
|
||||
|
||||
// getDescriptionFlag retrieves the description value, checking both --description and --body.
|
||||
// Returns the value and whether either flag was explicitly changed.
|
||||
func getDescriptionFlag(cmd *cobra.Command) (string, bool) {
|
||||
descChanged := cmd.Flags().Changed("description")
|
||||
bodyChanged := cmd.Flags().Changed("body")
|
||||
|
||||
// Error if both are specified with different values
|
||||
if descChanged && bodyChanged {
|
||||
desc, _ := cmd.Flags().GetString("description")
|
||||
body, _ := cmd.Flags().GetString("body")
|
||||
if desc != body {
|
||||
fmt.Fprintf(os.Stderr, "Error: cannot specify both --description and --body with different values\n")
|
||||
fmt.Fprintf(os.Stderr, " --description: %q\n", desc)
|
||||
fmt.Fprintf(os.Stderr, " --body: %q\n", body)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Return whichever was set (or description's value if neither)
|
||||
if bodyChanged {
|
||||
body, _ := cmd.Flags().GetString("body")
|
||||
return body, true
|
||||
}
|
||||
|
||||
desc, _ := cmd.Flags().GetString("description")
|
||||
return desc, descChanged
|
||||
}
|
||||
|
||||
// registerPriorityFlag registers the priority flag with a specific default value.
|
||||
func registerPriorityFlag(cmd *cobra.Command, defaultVal string) {
|
||||
cmd.Flags().StringP("priority", "p", defaultVal, "Priority (0-4 or P0-P4, 0=highest)")
|
||||
|
||||
@@ -368,8 +368,8 @@ var updateCmd = &cobra.Command{
|
||||
assignee, _ := cmd.Flags().GetString("assignee")
|
||||
updates["assignee"] = assignee
|
||||
}
|
||||
if cmd.Flags().Changed("description") {
|
||||
description, _ := cmd.Flags().GetString("description")
|
||||
description, descChanged := getDescriptionFlag(cmd)
|
||||
if descChanged {
|
||||
updates["description"] = description
|
||||
}
|
||||
if cmd.Flags().Changed("design") {
|
||||
|
||||
Reference in New Issue
Block a user