As originally designed in the issue discussion, a single function `NewCmdLock()` with a parameter to lock or unlock was proposed. However, after playing around with a couple different designs, it seems best to create two separate public functions and one private function to do the common work. Using two public functions seems to make sense because the api for locking is different from the api for unlocking. Therefore, the documentation for both are different and keeping them in separate functions would make it easier to maintain the documentation.
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
package issue
|
|
|
|
import (
|
|
"github.com/MakeNowJust/heredoc"
|
|
cmdClose "github.com/cli/cli/v2/pkg/cmd/issue/close"
|
|
cmdComment "github.com/cli/cli/v2/pkg/cmd/issue/comment"
|
|
cmdCreate "github.com/cli/cli/v2/pkg/cmd/issue/create"
|
|
cmdDelete "github.com/cli/cli/v2/pkg/cmd/issue/delete"
|
|
cmdEdit "github.com/cli/cli/v2/pkg/cmd/issue/edit"
|
|
cmdList "github.com/cli/cli/v2/pkg/cmd/issue/list"
|
|
cmdLock "github.com/cli/cli/v2/pkg/cmd/issue/lock"
|
|
cmdReopen "github.com/cli/cli/v2/pkg/cmd/issue/reopen"
|
|
cmdStatus "github.com/cli/cli/v2/pkg/cmd/issue/status"
|
|
cmdTransfer "github.com/cli/cli/v2/pkg/cmd/issue/transfer"
|
|
cmdView "github.com/cli/cli/v2/pkg/cmd/issue/view"
|
|
"github.com/cli/cli/v2/pkg/cmdutil"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func NewCmdIssue(f *cmdutil.Factory) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "issue <command>",
|
|
Short: "Manage issues",
|
|
Long: `Work with GitHub issues.`,
|
|
Example: heredoc.Doc(`
|
|
$ gh issue list
|
|
$ gh issue create --label bug
|
|
$ gh issue view --web
|
|
`),
|
|
Annotations: map[string]string{
|
|
"IsCore": "true",
|
|
"help:arguments": heredoc.Doc(`
|
|
An issue can be supplied as argument in any of the following formats:
|
|
- by number, e.g. "123"; or
|
|
- by URL, e.g. "https://github.com/OWNER/REPO/issues/123".
|
|
`),
|
|
},
|
|
}
|
|
|
|
cmdutil.EnableRepoOverride(cmd, f)
|
|
|
|
cmd.AddCommand(cmdClose.NewCmdClose(f, nil))
|
|
cmd.AddCommand(cmdCreate.NewCmdCreate(f, nil))
|
|
cmd.AddCommand(cmdList.NewCmdList(f, nil))
|
|
cmd.AddCommand(cmdLock.NewCmdLock(f, nil))
|
|
cmd.AddCommand(cmdReopen.NewCmdReopen(f, nil))
|
|
cmd.AddCommand(cmdStatus.NewCmdStatus(f, nil))
|
|
cmd.AddCommand(cmdLock.NewCmdUnlock(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))
|
|
|
|
return cmd
|
|
}
|