|
|
@ -9,6 +9,7 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
|
|
"code.gitea.io/sdk/gitea"
|
|
|
|
"code.gitea.io/sdk/gitea"
|
|
|
@ -27,32 +28,32 @@ var CmdLabels = cli.Command{
|
|
|
|
CmdLabelUpdate,
|
|
|
|
CmdLabelUpdate,
|
|
|
|
CmdLabelDelete,
|
|
|
|
CmdLabelDelete,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
Flags: append([]cli.Flag{
|
|
|
|
cli.StringFlag{
|
|
|
|
|
|
|
|
Name: "login, l",
|
|
|
|
|
|
|
|
Usage: "Indicate one login, optional when inside a gitea repository",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
cli.StringFlag{
|
|
|
|
|
|
|
|
Name: "repo, r",
|
|
|
|
|
|
|
|
Usage: "Indicate one repository, optional when inside a gitea repository",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
cli.StringFlag{
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "save, s",
|
|
|
|
Name: "save, s",
|
|
|
|
Usage: "Save all the labels as a file",
|
|
|
|
Usage: "Save all the labels as a file",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, AllDefaultFlags...),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func runLabels(ctx *cli.Context) error {
|
|
|
|
func runLabels(ctx *cli.Context) error {
|
|
|
|
login, owner, repo := initCommand()
|
|
|
|
login, owner, repo := initCommand()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
headers := []string{
|
|
|
|
|
|
|
|
"Index",
|
|
|
|
|
|
|
|
"Color",
|
|
|
|
|
|
|
|
"Name",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var values [][]string
|
|
|
|
|
|
|
|
|
|
|
|
labels, err := login.Client().ListRepoLabels(owner, repo)
|
|
|
|
labels, err := login.Client().ListRepoLabels(owner, repo)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if len(labels) == 0 {
|
|
|
|
if len(labels) == 0 {
|
|
|
|
fmt.Println("No Labels")
|
|
|
|
Output(outputValue, headers, values)
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -69,8 +70,16 @@ func runLabels(ctx *cli.Context) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
for _, label := range labels {
|
|
|
|
for _, label := range labels {
|
|
|
|
fmt.Fprintf(os.Stdout, "%d #%s %s\n", label.ID, label.Color, label.Name)
|
|
|
|
values = append(
|
|
|
|
|
|
|
|
values,
|
|
|
|
|
|
|
|
[]string{
|
|
|
|
|
|
|
|
strconv.FormatInt(label.ID, 10),
|
|
|
|
|
|
|
|
label.Color,
|
|
|
|
|
|
|
|
label.Name,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Output(outputValue, headers, values)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|