ParseArtifactArg is ParseArtifactArgs for a command that takes one artifact, { | }. A second artifact URL is always one too many, so it's refused before the URLs' issues and numbers are compared.
(args []string, baseRepo func() (ghrepo.Interface, error))
| 111 | // URL is always one too many, so it's refused before the URLs' issues and |
| 112 | // numbers are compared. |
| 113 | func ParseArtifactArg(args []string, baseRepo func() (ghrepo.Interface, error)) (int, func() (ghrepo.Interface, error), int, error) { |
| 114 | if len(args) > 1 && isArtifactURL(args[0]) && isArtifactURL(args[1]) { |
| 115 | return 0, nil, 0, errors.New("too many arguments") |
| 116 | } |
| 117 | issueNumber, repo, numbers, err := ParseArtifactArgs(args, baseRepo, false) |
| 118 | if err != nil { |
| 119 | return 0, nil, 0, err |
| 120 | } |
| 121 | if len(numbers) != 1 { |
| 122 | return 0, nil, 0, errors.New("too many arguments") |
| 123 | } |
| 124 | return issueNumber, repo, numbers[0], nil |
| 125 | } |
| 126 | |
| 127 | // artifactURLPath matches the path of an artifact's page on GitHub, the URL |
| 128 | // the API returns for it: /<owner>/<repo>/issues/<issue>/artifacts/<number>. |