parseInt parses a positive integer option value
( ctx context.Context, o *options.Options, key string, args ...string, )
| 116 | |
| 117 | // parseInt parses a positive integer option value |
| 118 | func (p *Parser) parseInt( |
| 119 | ctx context.Context, |
| 120 | o *options.Options, |
| 121 | key string, |
| 122 | args ...string, |
| 123 | ) error { |
| 124 | if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil { |
| 125 | return err |
| 126 | } |
| 127 | |
| 128 | i, err := strconv.Atoi(args[0]) |
| 129 | if err != nil { |
| 130 | return newInvalidArgumentError(ctx, key, args[0], "integer number") |
| 131 | } |
| 132 | |
| 133 | o.Set(key, i) |
| 134 | |
| 135 | return nil |
| 136 | } |
| 137 | |
| 138 | // parsePositiveNonZeroInt parses a positive non-zero integer option value |
| 139 | func (p *Parser) parsePositiveNonZeroInt( |
no test coverage detected