Split issue commands into "General" vs. "Targeted"

This commit is contained in:
Mislav Marohnić 2022-12-20 17:56:51 +01:00
parent a55dd656f3
commit 607a0876b9
No known key found for this signature in database
5 changed files with 35 additions and 23 deletions

View file

@ -65,7 +65,6 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
`),
Args: cmdutil.NoArgsQuoteReminder,
Aliases: []string{"new"},
GroupID: "general",
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override
opts.BaseRepo = f.BaseRepo

View file

@ -41,24 +41,24 @@ func NewCmdIssue(f *cmdutil.Factory) *cobra.Command {
cmdutil.EnableRepoOverride(cmd, f)
cmd.AddGroup(&cobra.Group{
ID: "general",
Title: "General commands",
})
cmdutil.AddGroup(cmd, "General commands",
cmdCreate.NewCmdCreate(f, nil),
cmdList.NewCmdList(f, nil),
cmdStatus.NewCmdStatus(f, nil),
)
cmd.AddCommand(cmdClose.NewCmdClose(f, nil))
cmd.AddCommand(cmdCreate.NewCmdCreate(f, nil))
cmd.AddCommand(cmdList.NewCmdList(f, nil))
cmd.AddCommand(cmdReopen.NewCmdReopen(f, nil))
cmd.AddCommand(cmdStatus.NewCmdStatus(f, nil))
cmd.AddCommand(cmdView.NewCmdView(f, nil))
cmd.AddCommand(cmdComment.NewCmdComment(f, nil))
cmd.AddCommand(cmdDelete.NewCmdDelete(f, nil))
cmd.AddCommand(cmdEdit.NewCmdEdit(f, nil))
cmd.AddCommand(cmdTransfer.NewCmdTransfer(f, nil))
cmd.AddCommand(cmdDevelop.NewCmdDevelop(f, nil))
cmd.AddCommand(cmdPin.NewCmdPin(f, nil))
cmd.AddCommand(cmdUnpin.NewCmdUnpin(f, nil))
cmdutil.AddGroup(cmd, "Targeted commands",
cmdClose.NewCmdClose(f, nil),
cmdReopen.NewCmdReopen(f, nil),
cmdView.NewCmdView(f, nil),
cmdComment.NewCmdComment(f, nil),
cmdDelete.NewCmdDelete(f, nil),
cmdEdit.NewCmdEdit(f, nil),
cmdTransfer.NewCmdTransfer(f, nil),
cmdDevelop.NewCmdDevelop(f, nil),
cmdPin.NewCmdPin(f, nil),
cmdUnpin.NewCmdUnpin(f, nil),
)
return cmd
}

View file

@ -73,7 +73,6 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
$ gh issue list --search "error no:assignee sort:created-asc"
`),
Aliases: []string{"ls"},
GroupID: "general",
Args: cmdutil.NoArgsQuoteReminder,
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override

View file

@ -32,10 +32,9 @@ func NewCmdStatus(f *cmdutil.Factory, runF func(*StatusOptions) error) *cobra.Co
}
cmd := &cobra.Command{
Use: "status",
Short: "Show status of relevant issues",
GroupID: "general",
Args: cmdutil.NoArgsQuoteReminder,
Use: "status",
Short: "Show status of relevant issues",
Args: cmdutil.NoArgsQuoteReminder,
RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override
opts.BaseRepo = f.BaseRepo

15
pkg/cmdutil/cmdgroup.go Normal file
View file

@ -0,0 +1,15 @@
package cmdutil
import "github.com/spf13/cobra"
func AddGroup(parent *cobra.Command, title string, cmds ...*cobra.Command) {
g := &cobra.Group{
Title: title,
ID: title,
}
parent.AddGroup(g)
for _, c := range cmds {
c.GroupID = g.ID
parent.AddCommand(c)
}
}