parseBool parses a boolean option value and warns if the value is invalid
( ctx context.Context, o *options.Options, key string, args ...string, )
| 31 | |
| 32 | // parseBool parses a boolean option value and warns if the value is invalid |
| 33 | func (p *Parser) parseBool( |
| 34 | ctx context.Context, |
| 35 | o *options.Options, |
| 36 | key string, |
| 37 | args ...string, |
| 38 | ) error { |
| 39 | if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil { |
| 40 | return err |
| 41 | } |
| 42 | |
| 43 | b, err := strconv.ParseBool(args[0]) |
| 44 | |
| 45 | if err != nil { |
| 46 | slog.Warn(fmt.Sprintf("%s `%s` is not a valid boolean value. Treated as false", key, args[0])) |
| 47 | } |
| 48 | |
| 49 | o.Set(key, b) |
| 50 | |
| 51 | return nil |
| 52 | } |
| 53 | |
| 54 | // parseFloat parses a float64 option value |
| 55 | func (p *Parser) parseFloat( |
no test coverage detected