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

Function ParseIssueArg

pkg/cmd/issue/artifact/shared/shared.go:40–49  ·  view source on GitHub ↗

ParseIssueArg reads an { | } argument the way other gh issue commands do, and returns the issue number and the function that resolves its repository. A URL names its own repository, so it works outside any repository and wins over baseRepo. A number uses baseRepo, which is n

(arg string, baseRepo func() (ghrepo.Interface, error))

Source from the content-addressed store, hash-verified

38// called here, so -R and GH_REPO still apply. Pull request URLs parse too, so
39// CheckIssue can refuse them with a clear message.
40func ParseIssueArg(arg string, baseRepo func() (ghrepo.Interface, error)) (int, func() (ghrepo.Interface, error), error) {
41 number, repo, err := issueShared.ParseIssueFromArg(arg)
42 if err != nil {
43 return 0, nil, err
44 }
45 if r, ok := repo.Value(); ok {
46 return number, func() (ghrepo.Interface, error) { return r, nil }, nil
47 }
48 return number, baseRepo, nil
49}
50
51// ParseArtifactNumber reads an <artifact-number> argument, which must be a
52// whole number of at least 1, so a mistyped number fails before any request.

Callers 4

NewCmdListFunction · 0.92
NewCmdCreateFunction · 0.92
TestParseIssueArgFunction · 0.85
ParseArtifactArgsFunction · 0.85

Calls 1

ValueMethod · 0.80

Tested by 1

TestParseIssueArgFunction · 0.68