Merge branch 'main' of https://github.com/steveyegge/beads
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -77,7 +77,7 @@ var createCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get field values, preferring explicit flags over template defaults
|
// Get field values, preferring explicit flags over template defaults
|
||||||
description, _ := cmd.Flags().GetString("description")
|
description, _ := getDescriptionFlag(cmd)
|
||||||
if description == "" && tmpl != nil {
|
if description == "" && tmpl != nil {
|
||||||
description = tmpl.Description
|
description = tmpl.Description
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,51 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/spf13/cobra"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
// registerCommonIssueFlags registers flags common to create and update commands.
|
// registerCommonIssueFlags registers flags common to create and update commands.
|
||||||
func registerCommonIssueFlags(cmd *cobra.Command) {
|
func registerCommonIssueFlags(cmd *cobra.Command) {
|
||||||
cmd.Flags().StringP("assignee", "a", "", "Assignee")
|
cmd.Flags().StringP("assignee", "a", "", "Assignee")
|
||||||
cmd.Flags().StringP("description", "d", "", "Issue description")
|
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("design", "", "Design notes")
|
||||||
cmd.Flags().String("acceptance", "", "Acceptance criteria")
|
cmd.Flags().String("acceptance", "", "Acceptance criteria")
|
||||||
cmd.Flags().String("external-ref", "", "External reference (e.g., 'gh-9', 'jira-ABC')")
|
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.
|
// registerPriorityFlag registers the priority flag with a specific default value.
|
||||||
func registerPriorityFlag(cmd *cobra.Command, defaultVal string) {
|
func registerPriorityFlag(cmd *cobra.Command, defaultVal string) {
|
||||||
cmd.Flags().StringP("priority", "p", defaultVal, "Priority (0-4 or P0-P4, 0=highest)")
|
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")
|
assignee, _ := cmd.Flags().GetString("assignee")
|
||||||
updates["assignee"] = assignee
|
updates["assignee"] = assignee
|
||||||
}
|
}
|
||||||
if cmd.Flags().Changed("description") {
|
description, descChanged := getDescriptionFlag(cmd)
|
||||||
description, _ := cmd.Flags().GetString("description")
|
if descChanged {
|
||||||
updates["description"] = description
|
updates["description"] = description
|
||||||
}
|
}
|
||||||
if cmd.Flags().Changed("design") {
|
if cmd.Flags().Changed("design") {
|
||||||
|
|||||||
Reference in New Issue
Block a user