(ctx context.Context, o *options.Options, args []string)
| 289 | } |
| 290 | |
| 291 | func (p *Parser) applyBackgroundOption(ctx context.Context, o *options.Options, args []string) error { |
| 292 | switch len(args) { |
| 293 | case 1: |
| 294 | if len(args[0]) == 0 { |
| 295 | o.Delete(keys.Background) |
| 296 | return nil |
| 297 | } |
| 298 | |
| 299 | if err := p.parseHexRGBColor(ctx, o, keys.Background, args[0]); err != nil { |
| 300 | return err |
| 301 | } |
| 302 | |
| 303 | case 3: |
| 304 | var c color.RGB |
| 305 | |
| 306 | if r, err := strconv.ParseUint(args[0], 10, 8); err == nil && r <= 255 { |
| 307 | c.R = uint8(r) |
| 308 | } else { |
| 309 | return newInvalidArgumentError(ctx, keys.Background+".R", args[0], "number in range 0-255") |
| 310 | } |
| 311 | |
| 312 | if g, err := strconv.ParseUint(args[1], 10, 8); err == nil && g <= 255 { |
| 313 | c.G = uint8(g) |
| 314 | } else { |
| 315 | return newInvalidArgumentError(ctx, keys.Background+".G", args[1], "number in range 0-255") |
| 316 | } |
| 317 | |
| 318 | if b, err := strconv.ParseUint(args[2], 10, 8); err == nil && b <= 255 { |
| 319 | c.B = uint8(b) |
| 320 | } else { |
| 321 | return newInvalidArgumentError(ctx, keys.Background+".B", args[2], "number in range 0-255") |
| 322 | } |
| 323 | |
| 324 | o.Set(keys.Background, c) |
| 325 | |
| 326 | default: |
| 327 | return newInvalidArgsError(ctx, keys.Background, args) |
| 328 | } |
| 329 | |
| 330 | return nil |
| 331 | } |
| 332 | |
| 333 | func (p *Parser) applyBlurOption(ctx context.Context, o *options.Options, args []string) error { |
| 334 | return p.parsePositiveFloat(ctx, o, keys.Blur, args...) |
no test coverage detected