MCPcopy
hub / github.com/cli/cli / NewCmdTransfer

Function NewCmdTransfer

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

Source from the content-addressed store, hash-verified

25}
26
27func NewCmdTransfer(f *cmdutil.Factory, runF func(*TransferOptions) error) *cobra.Command {
28 opts := TransferOptions{
29 IO: f.IOStreams,
30 HttpClient: f.HttpClient,
31 Config: f.Config,
32 }
33
34 cmd := &cobra.Command{
35 Use: "transfer {<number> | <url>} <destination-repo>",
36 Short: "Transfer issue to another repository",
37 Args: cmdutil.ExactArgs(2, "issue and destination repository are required"),
38 RunE: func(cmd *cobra.Command, args []string) error {
39 issueNumber, baseRepo, err := shared.ParseIssueFromArg(args[0])
40 if err != nil {
41 return err
42 }
43
44 // If the args provided the base repo then use that directly.
45 if baseRepo, present := baseRepo.Value(); present {
46 opts.BaseRepo = func() (ghrepo.Interface, error) {
47 return baseRepo, nil
48 }
49 } else {
50 // support `-R, --repo` override
51 opts.BaseRepo = f.BaseRepo
52 }
53
54 opts.IssueNumber = issueNumber
55
56 opts.DestRepoSelector = args[1]
57
58 if runF != nil {
59 return runF(&opts)
60 }
61
62 return transferRun(&opts)
63 },
64 }
65
66 return cmd
67}
68
69func transferRun(opts *TransferOptions) error {
70 httpClient, err := opts.HttpClient()

Callers 2

runCommandFunction · 0.85
TestNewCmdTransferFunction · 0.85

Calls 4

ExactArgsFunction · 0.92
ParseIssueFromArgFunction · 0.92
transferRunFunction · 0.85
ValueMethod · 0.80

Tested by 2

runCommandFunction · 0.68
TestNewCmdTransferFunction · 0.68