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

Function ParseArtifactArg

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

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))

Source from the content-addressed store, hash-verified

111// URL is always one too many, so it's refused before the URLs' issues and
112// numbers are compared.
113func 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>.

Callers 3

NewCmdViewFunction · 0.92
NewCmdEditFunction · 0.92
TestParseArtifactArgFunction · 0.85

Calls 2

isArtifactURLFunction · 0.85
ParseArtifactArgsFunction · 0.85

Tested by 1

TestParseArtifactArgFunction · 0.68