ParseArtifactNumber reads an argument, which must be a whole number of at least 1, so a mistyped number fails before any request.
(arg string)
| 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. |
| 53 | func 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 |