From c8b4eb2ea0fa9e2c0945c9b24cb6ba4ad560e7da Mon Sep 17 00:00:00 2001 From: 15972095207 <2484216370@qq.com> Date: Thu, 4 Jun 2026 09:10:15 +0800 Subject: [PATCH] feat: add --label support to issue update command Support setting or clearing labels on existing issues: - --label 327264,327265 set labels - --label "" clear all labels Co-Authored-By: Claude Opus 4.8 --- shortcuts/issue/issue.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/shortcuts/issue/issue.go b/shortcuts/issue/issue.go index d38e529..5e83ffd 100644 --- a/shortcuts/issue/issue.go +++ b/shortcuts/issue/issue.go @@ -161,6 +161,7 @@ func Shortcuts() []*common.Shortcut { {Name: "title", Short: "t", Usage: "New title"}, {Name: "body", Short: "b", Usage: "New description"}, {Name: "state", Short: "s", Usage: "New state: open, closed, or numeric status_id"}, + {Name: "label", Short: "l", Usage: "Label IDs (comma-separated, empty to clear)"}, }, Run: func(ctx *common.RuntimeContext) error { if err := ctx.ResolveOwnerRepo(); err != nil { @@ -173,8 +174,9 @@ func Shortcuts() []*common.Shortcut { title := ctx.Arg("title") description := ctx.Arg("body") state := ctx.Arg("state") - if title == "" && description == "" && state == "" { - return fmt.Errorf("at least one of --title, --body, or --state is required") + _, labelProvided := ctx.Args["label"] + if title == "" && description == "" && state == "" && !labelProvided { + return fmt.Errorf("at least one of --title, --body, --state, or --label is required") } current, err := fetchExistingIssue(ctx, number) @@ -199,6 +201,22 @@ func Shortcuts() []*common.Shortcut { } body["status_id"] = statusID } + if labelProvided { + if l := ctx.Arg("label"); l != "" { + var tagIDs []int + for _, s := range strings.Split(l, ",") { + s = strings.TrimSpace(s) + if id, err := strconv.Atoi(s); err == nil { + tagIDs = append(tagIDs, id) + } + } + if len(tagIDs) > 0 { + body["issue_tag_ids"] = tagIDs + } + } else { + body["issue_tag_ids"] = []int{} + } + } env, err := ctx.CallAPI("PATCH", fmt.Sprintf("%s/issues/%s", v1RepoPath(ctx), number), body) if err != nil { return err