MCPcopy
hub / github.com/cli/cli / addRun

Function addRun

pkg/cmd/repo/deploy-key/add/add.go:64–99  ·  view source on GitHub ↗
(opts *AddOptions)

Source from the content-addressed store, hash-verified

62}
63
64func addRun(opts *AddOptions) error {
65 httpClient, err := opts.HTTPClient()
66 if err != nil {
67 return err
68 }
69
70 var keyReader io.Reader
71 if opts.KeyFile == "-" {
72 keyReader = opts.IO.In
73 defer opts.IO.In.Close()
74 } else {
75 f, err := os.Open(opts.KeyFile)
76 if err != nil {
77 return err
78 }
79 defer f.Close()
80 keyReader = f
81 }
82
83 repo, err := opts.BaseRepo()
84 if err != nil {
85 return err
86 }
87
88 if err := uploadDeployKey(httpClient, repo, keyReader, opts.Title, opts.AllowWrite); err != nil {
89 return err
90 }
91
92 if !opts.IO.IsStdoutTTY() {
93 return nil
94 }
95
96 cs := opts.IO.ColorScheme()
97 _, err = fmt.Fprintf(opts.IO.Out, "%s Deploy key added to %s\n", cs.SuccessIcon(), cs.Bold(ghrepo.FullName(repo)))
98 return err
99}

Callers 2

Test_addRunFunction · 0.85
NewCmdAddFunction · 0.85

Calls 9

FullNameFunction · 0.92
uploadDeployKeyFunction · 0.85
OpenMethod · 0.80
IsStdoutTTYMethod · 0.80
ColorSchemeMethod · 0.80
SuccessIconMethod · 0.80
BoldMethod · 0.80
CloseMethod · 0.65
BaseRepoMethod · 0.65

Tested by 1

Test_addRunFunction · 0.68