MCPcopy
hub / github.com/cli/cli / NewCmdReopen

Function NewCmdReopen

pkg/cmd/issue/reopen/reopen.go:28–67  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*ReopenOptions) error)

Source from the content-addressed store, hash-verified

26}
27
28func NewCmdReopen(f *cmdutil.Factory, runF func(*ReopenOptions) error) *cobra.Command {
29 opts := &ReopenOptions{
30 IO: f.IOStreams,
31 HttpClient: f.HttpClient,
32 Config: f.Config,
33 }
34
35 cmd := &cobra.Command{
36 Use: "reopen {<number> | <url>}",
37 Short: "Reopen issue",
38 Args: cobra.ExactArgs(1),
39 RunE: func(cmd *cobra.Command, args []string) error {
40 issueNumber, baseRepo, err := shared.ParseIssueFromArg(args[0])
41 if err != nil {
42 return err
43 }
44
45 // If the args provided the base repo then use that directly.
46 if baseRepo, present := baseRepo.Value(); present {
47 opts.BaseRepo = func() (ghrepo.Interface, error) {
48 return baseRepo, nil
49 }
50 } else {
51 // support `-R, --repo` override
52 opts.BaseRepo = f.BaseRepo
53 }
54
55 opts.IssueNumber = issueNumber
56
57 if runF != nil {
58 return runF(opts)
59 }
60 return reopenRun(opts)
61 },
62 }
63
64 cmd.Flags().StringVarP(&opts.Comment, "comment", "c", "", "Add a reopening comment")
65
66 return cmd
67}
68
69func reopenRun(opts *ReopenOptions) error {
70 cs := opts.IO.ColorScheme()

Callers 1

runCommandFunction · 0.70

Calls 2

ValueMethod · 0.80
reopenRunFunction · 0.70

Tested by 1

runCommandFunction · 0.56