parsePositiveInt parses a positive integer option value
( ctx context.Context, o *options.Options, key string, args ...string, )
| 158 | |
| 159 | // parsePositiveInt parses a positive integer option value |
| 160 | func (p *Parser) parsePositiveInt( |
| 161 | ctx context.Context, |
| 162 | o *options.Options, |
| 163 | key string, |
| 164 | args ...string, |
| 165 | ) error { |
| 166 | if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil { |
| 167 | return err |
| 168 | } |
| 169 | |
| 170 | i, err := strconv.Atoi(args[0]) |
| 171 | if err != nil || i < 0 { |
| 172 | return newInvalidArgumentError(ctx, key, args[0], "positive number or 0") |
| 173 | } |
| 174 | |
| 175 | o.Set(key, i) |
| 176 | |
| 177 | return nil |
| 178 | } |
| 179 | |
| 180 | // parseQualityInt parses a quality integer option value (minQ-100) |
| 181 | func (p *Parser) parseQualityInt( |
no test coverage detected