| 23 | } |
| 24 | |
| 25 | func NewCmdReopen(f *cmdutil.Factory, runF func(*ReopenOptions) error) *cobra.Command { |
| 26 | opts := &ReopenOptions{ |
| 27 | IO: f.IOStreams, |
| 28 | HttpClient: f.HttpClient, |
| 29 | } |
| 30 | |
| 31 | cmd := &cobra.Command{ |
| 32 | Use: "reopen {<number> | <url> | <branch>}", |
| 33 | Short: "Reopen a pull request", |
| 34 | Args: cobra.ExactArgs(1), |
| 35 | RunE: func(cmd *cobra.Command, args []string) error { |
| 36 | opts.Finder = shared.NewFinder(f) |
| 37 | |
| 38 | if len(args) > 0 { |
| 39 | opts.SelectorArg = args[0] |
| 40 | } |
| 41 | |
| 42 | if runF != nil { |
| 43 | return runF(opts) |
| 44 | } |
| 45 | return reopenRun(opts) |
| 46 | }, |
| 47 | } |
| 48 | |
| 49 | cmd.Flags().StringVarP(&opts.Comment, "comment", "c", "", "Add a reopening comment") |
| 50 | |
| 51 | return cmd |
| 52 | } |
| 53 | |
| 54 | func reopenRun(opts *ReopenOptions) error { |
| 55 | cs := opts.IO.ColorScheme() |