MCPcopy
hub / github.com/cli/cli / NewCmdClose

Function NewCmdClose

pkg/cmd/pr/close/close.go:31–63  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*CloseOptions) error)

Source from the content-addressed store, hash-verified

29}
30
31func NewCmdClose(f *cmdutil.Factory, runF func(*CloseOptions) error) *cobra.Command {
32 opts := &CloseOptions{
33 IO: f.IOStreams,
34 HttpClient: f.HttpClient,
35 GitClient: f.GitClient,
36 Branch: f.Branch,
37 }
38
39 cmd := &cobra.Command{
40 Use: "close {<number> | <url> | <branch>}",
41 Short: "Close a pull request",
42 Args: cmdutil.ExactArgs(1, "cannot close pull request: number, url, or branch required"),
43 RunE: func(cmd *cobra.Command, args []string) error {
44 opts.Finder = shared.NewFinder(f)
45
46 if len(args) > 0 {
47 opts.SelectorArg = args[0]
48 }
49
50 opts.DeleteLocalBranch = !cmd.Flags().Changed("repo")
51
52 if runF != nil {
53 return runF(opts)
54 }
55 return closeRun(opts)
56 },
57 }
58
59 cmd.Flags().StringVarP(&opts.Comment, "comment", "c", "", "Leave a closing comment")
60 cmd.Flags().BoolVarP(&opts.DeleteBranch, "delete-branch", "d", false, "Delete the local and remote branch after close")
61
62 return cmd
63}
64
65func closeRun(opts *CloseOptions) error {
66 cs := opts.IO.ColorScheme()

Callers 1

runCommandFunction · 0.70

Calls 3

ExactArgsFunction · 0.92
NewFinderFunction · 0.92
closeRunFunction · 0.70

Tested by 1

runCommandFunction · 0.56