MCPcopy Create free account
hub / github.com/cli/cli / parseRepoArgs

Function parseRepoArgs

script/ghmock/gitcmd.go:24–41  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

22}
23
24func parseRepoArgs(args []string) (repoOptions, error) {
25 var opts repoOptions
26 fs := flag.NewFlagSet("repo", flag.ContinueOnError)
27 fs.SetOutput(io.Discard)
28 fs.StringVar(&opts.branch, "branch", "main", "initial branch")
29 name, err := parseWithName(fs, args)
30 if err != nil {
31 return repoOptions{}, err
32 }
33 if _, _, err := parseGitRepo(name); err != nil {
34 return repoOptions{}, usageError{err}
35 }
36 if opts.branch == "" {
37 return repoOptions{}, newUsageError("--branch cannot be empty")
38 }
39 opts.name = name
40 return opts, nil
41}
42
43func cmdRepo(args []string, stdout io.Writer) error {
44 opts, err := parseRepoArgs(args)

Callers 2

TestParseRepoArgsFunction · 0.85
cmdRepoFunction · 0.85

Calls 3

parseWithNameFunction · 0.85
parseGitRepoFunction · 0.85
newUsageErrorFunction · 0.85

Tested by 1

TestParseRepoArgsFunction · 0.68