MCPcopy
hub / github.com/cli/cli / createRun

Function createRun

pkg/cmd/repo/create/create.go:263–292  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

261}
262
263func createRun(opts *CreateOptions) error {
264 if opts.Interactive {
265 cfg, err := opts.Config()
266 if err != nil {
267 return err
268 }
269 host, _ := cfg.Authentication().DefaultHost()
270 answer, err := opts.Prompter.Select("What would you like to do?", "", []string{
271 fmt.Sprintf("Create a new repository on %s from scratch", host),
272 fmt.Sprintf("Create a new repository on %s from a template repository", host),
273 fmt.Sprintf("Push an existing local repository to %s", host),
274 })
275 if err != nil {
276 return err
277 }
278 switch answer {
279 case 0:
280 return createFromScratch(opts)
281 case 1:
282 return createFromTemplate(opts)
283 case 2:
284 return createFromLocal(opts)
285 }
286 }
287
288 if opts.Source == "" {
289 return createFromScratch(opts)
290 }
291 return createFromLocal(opts)
292}
293
294// create new repo on remote host
295func createFromScratch(opts *CreateOptions) error {

Callers 2

Test_createRunFunction · 0.70
NewCmdCreateFunction · 0.70

Calls 7

createFromScratchFunction · 0.85
createFromTemplateFunction · 0.85
createFromLocalFunction · 0.85
ConfigMethod · 0.65
DefaultHostMethod · 0.65
AuthenticationMethod · 0.65
SelectMethod · 0.65

Tested by 1

Test_createRunFunction · 0.56