Compare commits
3 Commits
8364201d7b
...
4f964c4b2c
Author | SHA1 | Date | |
---|---|---|---|
4f964c4b2c | |||
78ede4a084 | |||
30ffe76a4b |
@ -1 +1,11 @@
|
||||
access_token = "token"
|
||||
access_token = "token"
|
||||
|
||||
[colors]
|
||||
purple_candy = [ 280.0, 0.29, 0.71 ]
|
||||
wasabi = [ 120.0, 1.0, 0.7 ]
|
||||
honeydew = [ 120.0, 1.0, 0.97 ]
|
||||
green_mist = [ 92.0, 0.72, 0.75 ]
|
||||
pea = [ 90.0, 0.42, 0.47 ]
|
||||
cat_eye = [ 76.0, 0.74, 0.61 ]
|
||||
seagreen = [ 160.0, 1.0, 0.50 ]
|
||||
blue_mist = [ 202.0, 0.97, 0.75 ]
|
@ -100,5 +100,31 @@ func (c *Config) Validate() error {
|
||||
if c.AccessToken == "" {
|
||||
err = errors.New("access_token is not set")
|
||||
}
|
||||
|
||||
if err = c.validateColors(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Config) validateColors() (err error) {
|
||||
if len(c.Colors) > 0 {
|
||||
for name, hsb := range c.Colors {
|
||||
if len(hsb) != 3 {
|
||||
return fmt.Errorf("color '%s' needs three values", name)
|
||||
}
|
||||
h, s, b := hsb[0], hsb[1], hsb[2]
|
||||
if h < 0 || h > 360 {
|
||||
return fmt.Errorf("color '%s' hue value must be between 0.0-360.0", name)
|
||||
}
|
||||
if s < 0 || b > 1 {
|
||||
return fmt.Errorf("color '%s' saturation value must be between 0.0-1.0", name)
|
||||
}
|
||||
if b < 0 || b > 1 {
|
||||
return fmt.Errorf("color '%s' brightness value must be between 0.0-1.0", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ func Main(args []string) (int, error) {
|
||||
}
|
||||
|
||||
if _, err := toml.DecodeFile(configPath, &config); err != nil {
|
||||
err = fmt.Errorf("fatal: failed to parse %s", configPath)
|
||||
err = fmt.Errorf("fatal: failed to parse %s; %w", configPath, err)
|
||||
return ExitError, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user