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))
| 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. |
| 40 | func 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. |