feat(label): edit a label in a form without flags

label edit without flags on a terminal now opens a form with the label's
name, color, description and flags, like milestone edit and issue edit,
instead of failing; without a terminal it reports the shared "nothing to
edit" error. The help of issue and milestone close and reopen names its
commands without generating the text from the verb.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 00:17:08 +02:00
1 parent f6a0d18b8a
commit 5d2f2d83eb
6 files changed
+143 -8

No files matched your search

+17 -2
View File
@@ -240,14 +240,19 @@ func (a *application) reportLabel(cmd *cobra.Command, s services.Labels, item se
func (a *application) labelEditCommand(scope labelScope, complete cobra.CompletionFunc) *cobra.Command {
var fields labelFields
var byName bool
cmd := &cobra.Command{Use: "edit <label>", Short: "Edit a label", Example: `$ tea label edit bug --name defect --color b60205
cmd := &cobra.Command{Use: "edit <label>", Short: "Edit a label", Long: "Edit a label. Without flags on a terminal, a form starts from the current values.", Example: `$ tea label edit bug --name defect --color b60205
$ tea label edit "kind/question" --description "Further information is requested"
$ tea label edit old-stuff --archived`, Annotations: map[string]string{"tea.arguments": labelArguments}, Args: argsExact(1), RunE: func(cmd *cobra.Command, args []string) error {
opts, err := fields.options(cmd)
if err != nil {
return err
}
if opts == (services.LabelOptions{}) {
prompt, err := a.canPrompt()
if err != nil {
return err
}
form, hasForm := a.deps.Prompter.(terminal.LabelForm)
if opts == (services.LabelOptions{}) && (!prompt || !hasForm) {
return errNothingToEdit
}
s, err := scope(cmd)
@@ -258,6 +263,16 @@ $ tea label edit old-stuff --archived`, Annotations: map[string]string{"tea.argu
if err != nil {
return err
}
if opts == (services.LabelOptions{}) {
current := found[0]
values, err := form.EditLabel(cmd.Context(), "Editing "+labelName(s, current), terminal.LabelFormValues{
Name: current.Name, Color: current.Color, Description: current.Description, Exclusive: current.Exclusive, Archived: current.Archived,
})
if err != nil {
return err
}
opts = services.LabelOptions{Name: &values.Name, Color: &values.Color, Description: &values.Description, Exclusive: &values.Exclusive, Archived: &values.Archived}
}
item, err := s.Edit(cmd.Context(), found[0].ID, opts)
if err != nil {
return err