feat(label): address labels by name and add import and clone

label edit bug and label delete kind/feature failed with "invalid resource
number", and label create took its name as --name and required
--color. Like gh, label create takes the name as an argument and picks
a random color without -c; label edit and delete take names or IDs
(delete several at once, after a confirmation that names them), and
-c/-d/-n/-f are the gh short flags. Without a name on a terminal, label
create asks for the name, color and description.

label list shows ID NAME COLOR DESCRIPTION FLAGS with a colored swatch
and exclusive and archived labels flagged. Mutations report ✓ lines.
label import reads a label file or stdin (label create --file still
works), label clone copies another repository's labels, skipping those
that exist unless --force, and label export writes to stdout by default
or to -O/--output.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 00:16:09 +02:00
1 parent 10417049a1
commit 2ba02cf915
10 files changed
+583 -194

No files matched your search

+13 -7
View File
@@ -7,18 +7,23 @@ import (
"io"
"strings"
"gitea.dev/tea/internal/services"
"gitea.dev/tea/internal/terminal"
"github.com/spf13/cobra"
)
func (a *application) labelExportCommand(service func(*cobra.Command) (services.Labels, error)) *cobra.Command {
func (a *application) labelExportCommand(scope labelScope) *cobra.Command {
var output string
command := &cobra.Command{Use: "export", Short: "Export all labels in the selected scope", Args: argsExact(0), RunE: func(cmd *cobra.Command, _ []string) error {
if err := validateDownloadDestination(output); err != nil {
return err
command := &cobra.Command{Use: "export", Short: "Export labels to a label file", Long: `Write every label as a row of a label file, the format tea label import reads, to standard
output or to a new file.`, Example: `$ tea label export > labels.txt
$ tea label export --org acme --output labels.txt
# Copy the labels of one repository to another
$ tea label export -R alice/old | tea label import - -R alice/new`, Args: argsExact(0), RunE: func(cmd *cobra.Command, _ []string) error {
if output != "" {
if err := validateDownloadDestination(output); err != nil {
return err
}
}
labels, err := service(cmd)
labels, err := scope(cmd)
if err != nil {
return err
}
@@ -42,6 +47,7 @@ func (a *application) labelExportCommand(service func(*cobra.Command) (services.
return err
})
}}
command.Flags().StringVar(&output, "output-file", "", "New export file, or - for stdout")
command.Flags().StringVarP(&output, "output", "O", "", "Write to a new `file` instead of standard output")
flagAliases(command, map[string]string{"output-file": "output"})
return command
}