Add the label command

This command can currently only list the labels associated with a git
repository. In the future, it will also allow the creation of new
labels and modifiaction of existing labels.
上级 ff90d383
package commands
import (
"github.com/github/hub/github"
"github.com/github/hub/ui"
"github.com/github/hub/utils"
)
var (
cmdLabel = &Command{
Run: listLabels,
Usage: `
label
`,
Long: `Manage GitHub labels for the current repository.
## Commands:
With no arguments, show a list of open issues.
`,
}
)
func init() {
CmdRunner.Use(cmdLabel)
}
func listLabels(cmd *Command, args *Args) {
localRepo, err := github.LocalRepo()
utils.Check(err)
project, err := localRepo.MainProject()
utils.Check(err)
gh := github.NewClient(project.Host)
if args.Noop {
ui.Printf("Would request list of labels for %s\n", project)
} else {
labels, err := gh.FetchLabels(project)
utils.Check(err)
for _, label := range labels {
ui.Printf(formatLabel(label))
}
}
args.NoForward()
}
func formatLabel(label github.IssueLabel) string {
format := "%l%n"
placeholders := map[string]string{
"l": label.Name,
}
return ui.Expand(format, placeholders, false)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册