ParseArtifactArgs reads the arguments of a command that names artifacts in either of two forms, { ... | ...}, and returns the issue number, the function that resolves its repository, and the artifact numbers in argument order. args must not be empty, which the c
(args []string, baseRepo func() (ghrepo.Interface, error), issueAlone bool)
| 82 | // numbers are empty. Without it, a lone argument that isn't an artifact URL |
| 83 | // names no artifact, which fails with MissingArtifactMessage. |
| 84 | func ParseArtifactArgs(args []string, baseRepo func() (ghrepo.Interface, error), issueAlone bool) (int, func() (ghrepo.Interface, error), []int, error) { |
| 85 | if isArtifactURL(args[0]) { |
| 86 | return parseArtifactURLs(args) |
| 87 | } |
| 88 | if len(args) == 1 && !issueAlone { |
| 89 | return 0, nil, nil, errors.New(MissingArtifactMessage) |
| 90 | } |
| 91 | |
| 92 | issueNumber, repo, err := ParseIssueArg(args[0], baseRepo) |
| 93 | if err != nil { |
| 94 | return 0, nil, nil, err |
| 95 | } |
| 96 | numbers := make([]int, 0, len(args)-1) |
| 97 | for _, arg := range args[1:] { |
| 98 | number, err := ParseArtifactNumber(arg) |
| 99 | if err != nil { |
| 100 | return 0, nil, nil, err |
| 101 | } |
| 102 | if numbers, err = appendNew(numbers, number); err != nil { |
| 103 | return 0, nil, nil, err |
| 104 | } |
| 105 | } |
| 106 | return issueNumber, repo, numbers, nil |
| 107 | } |
| 108 | |
| 109 | // ParseArtifactArg is ParseArtifactArgs for a command that takes one |
| 110 | // artifact, {<issue> <artifact-number> | <artifact-url>}. A second artifact |