parseHexRGBColor parses a hex-encoded RGB color option value
( ctx context.Context, o *options.Options, key string, args ...string, )
| 265 | |
| 266 | // parseHexRGBColor parses a hex-encoded RGB color option value |
| 267 | func (p *Parser) parseHexRGBColor( |
| 268 | ctx context.Context, |
| 269 | o *options.Options, |
| 270 | key string, |
| 271 | args ...string, |
| 272 | ) error { |
| 273 | if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil { |
| 274 | return err |
| 275 | } |
| 276 | |
| 277 | c, err := color.RGBFromHex(args[0]) |
| 278 | if err != nil { |
| 279 | return newInvalidArgumentError(ctx, key, args[0], "hex-encoded color") |
| 280 | } |
| 281 | |
| 282 | o.Set(key, c) |
| 283 | |
| 284 | return nil |
| 285 | } |
| 286 | |
| 287 | // parseFromMap parses an option value from a map of allowed values |
| 288 | func parseFromMap[T comparable]( |
no test coverage detected