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

Function ParseArtifactNumber

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

ParseArtifactNumber reads an argument, which must be a whole number of at least 1, so a mistyped number fails before any request.

(arg string)

Source from the content-addressed store, hash-verified

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.
53func ParseArtifactNumber(arg string) (int, error) {
54 number, err := strconv.Atoi(arg)
55 if err != nil || number < 1 {
56 return 0, fmt.Errorf("invalid artifact number: %q", arg)
57 }
58 return number, nil
59}
60
61// MissingArtifactMessage is the usage error for a command that needs an
62// artifact when none is named: no arguments, or a lone argument that isn't an

Callers 2

TestParseArtifactNumberFunction · 0.85
ParseArtifactArgsFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by 1

TestParseArtifactNumberFunction · 0.68