feat(update): add --type flag to bd update command (GH#522)
Allow changing an issue type (bug, feature, task, epic, chore) via the bd update command. The storage layer already supported issue_type in allowedUpdateFields, this just exposes it through the CLI. Changes: - Add --type/-t flag to updateCmd in show.go - Add IssueType field to UpdateArgs in protocol.go - Handle issue_type in updatesFromArgs in server_issues_epics.go - Add validation using ParseIssueType before update Example usage: bd update ab-xyz --type epic Fixes: #522
This commit is contained in:
@@ -30,3 +30,5 @@ beads.right.meta.json
|
|||||||
!issues.jsonl
|
!issues.jsonl
|
||||||
!metadata.json
|
!metadata.json
|
||||||
!config.json
|
!config.json
|
||||||
|
deletions.jsonl
|
||||||
|
deletions.jsonl.migrated
|
||||||
|
|||||||
+224
-207
File diff suppressed because one or more lines are too long
@@ -526,6 +526,15 @@ var updateCmd = &cobra.Command{
|
|||||||
setLabels, _ := cmd.Flags().GetStringSlice("set-labels")
|
setLabels, _ := cmd.Flags().GetStringSlice("set-labels")
|
||||||
updates["set_labels"] = setLabels
|
updates["set_labels"] = setLabels
|
||||||
}
|
}
|
||||||
|
if cmd.Flags().Changed("type") {
|
||||||
|
issueType, _ := cmd.Flags().GetString("type")
|
||||||
|
// Validate issue type
|
||||||
|
if _, err := validation.ParseIssueType(issueType); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
updates["issue_type"] = issueType
|
||||||
|
}
|
||||||
|
|
||||||
if len(updates) == 0 {
|
if len(updates) == 0 {
|
||||||
fmt.Println("No updates specified")
|
fmt.Println("No updates specified")
|
||||||
@@ -606,6 +615,9 @@ var updateCmd = &cobra.Command{
|
|||||||
if setLabels, ok := updates["set_labels"].([]string); ok {
|
if setLabels, ok := updates["set_labels"].([]string); ok {
|
||||||
updateArgs.SetLabels = setLabels
|
updateArgs.SetLabels = setLabels
|
||||||
}
|
}
|
||||||
|
if issueType, ok := updates["issue_type"].(string); ok {
|
||||||
|
updateArgs.IssueType = &issueType
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := daemonClient.Update(updateArgs)
|
resp, err := daemonClient.Update(updateArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1019,6 +1031,7 @@ func init() {
|
|||||||
updateCmd.Flags().StringP("status", "s", "", "New status")
|
updateCmd.Flags().StringP("status", "s", "", "New status")
|
||||||
registerPriorityFlag(updateCmd, "")
|
registerPriorityFlag(updateCmd, "")
|
||||||
updateCmd.Flags().String("title", "", "New title")
|
updateCmd.Flags().String("title", "", "New title")
|
||||||
|
updateCmd.Flags().StringP("type", "t", "", "New type (bug|feature|task|epic|chore)")
|
||||||
registerCommonIssueFlags(updateCmd)
|
registerCommonIssueFlags(updateCmd)
|
||||||
updateCmd.Flags().String("notes", "", "Additional notes")
|
updateCmd.Flags().String("notes", "", "Additional notes")
|
||||||
updateCmd.Flags().String("acceptance-criteria", "", "DEPRECATED: use --acceptance")
|
updateCmd.Flags().String("acceptance-criteria", "", "DEPRECATED: use --acceptance")
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ type UpdateArgs struct {
|
|||||||
Assignee *string `json:"assignee,omitempty"`
|
Assignee *string `json:"assignee,omitempty"`
|
||||||
ExternalRef *string `json:"external_ref,omitempty"` // Link to external issue trackers
|
ExternalRef *string `json:"external_ref,omitempty"` // Link to external issue trackers
|
||||||
EstimatedMinutes *int `json:"estimated_minutes,omitempty"` // Time estimate in minutes
|
EstimatedMinutes *int `json:"estimated_minutes,omitempty"` // Time estimate in minutes
|
||||||
|
IssueType *string `json:"issue_type,omitempty"` // Issue type (bug, feature, task, epic, chore)
|
||||||
AddLabels []string `json:"add_labels,omitempty"`
|
AddLabels []string `json:"add_labels,omitempty"`
|
||||||
RemoveLabels []string `json:"remove_labels,omitempty"`
|
RemoveLabels []string `json:"remove_labels,omitempty"`
|
||||||
SetLabels []string `json:"set_labels,omitempty"`
|
SetLabels []string `json:"set_labels,omitempty"`
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ func updatesFromArgs(a UpdateArgs) map[string]interface{} {
|
|||||||
if a.EstimatedMinutes != nil {
|
if a.EstimatedMinutes != nil {
|
||||||
u["estimated_minutes"] = *a.EstimatedMinutes
|
u["estimated_minutes"] = *a.EstimatedMinutes
|
||||||
}
|
}
|
||||||
|
if a.IssueType != nil {
|
||||||
|
u["issue_type"] = *a.IssueType
|
||||||
|
}
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user