MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / parseBool

Method parseBool

options/parser/parse.go:33–52  ·  view source on GitHub ↗

parseBool parses a boolean option value and warns if the value is invalid

(
	ctx context.Context,
	o *options.Options,
	key string,
	args ...string,
)

Source from the content-addressed store, hash-verified

31
32// parseBool parses a boolean option value and warns if the value is invalid
33func (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
55func (p *Parser) parseFloat(

Callers 12

applyEnlargeOptionMethod · 0.95
applyTrimOptionMethod · 0.95
applyFlipOptionMethod · 0.95
applyRawOptionMethod · 0.95
applyAutoRotateOptionMethod · 0.95
parseExtendMethod · 0.95

Calls 3

ensureMaxArgsMethod · 0.95
WarnMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected