parsePositiveNonZeroInt parses a positive non-zero integer option value
( ctx context.Context, o *options.Options, key string, args ...string, )
| 137 | |
| 138 | // parsePositiveNonZeroInt parses a positive non-zero integer option value |
| 139 | func (p *Parser) parsePositiveNonZeroInt( |
| 140 | ctx context.Context, |
| 141 | o *options.Options, |
| 142 | key string, |
| 143 | args ...string, |
| 144 | ) error { |
| 145 | if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil { |
| 146 | return err |
| 147 | } |
| 148 | |
| 149 | i, err := strconv.Atoi(args[0]) |
| 150 | if err != nil || i <= 0 { |
| 151 | return newInvalidArgumentError(ctx, key, args[0], "positive number") |
| 152 | } |
| 153 | |
| 154 | o.Set(key, i) |
| 155 | |
| 156 | return nil |
| 157 | } |
| 158 | |
| 159 | // parsePositiveInt parses a positive integer option value |
| 160 | func (p *Parser) parsePositiveInt( |
no test coverage detected