Compare commits
3 Commits
d5db68dbfa
...
88d7d7a0b4
Author | SHA1 | Date | |
---|---|---|---|
88d7d7a0b4 | |||
1f87c72e34 | |||
454bfbf61d |
@ -60,6 +60,13 @@ func (c *Config) validateColors() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Config) MergeWithEnv() {
|
||||
envAccessToken := os.Getenv("LIFX_ACCESS_TOKEN")
|
||||
if envAccessToken != "" {
|
||||
c.AccessToken = envAccessToken
|
||||
}
|
||||
}
|
||||
|
||||
func LoadConfig(s string) (*Config, error) {
|
||||
var err error
|
||||
var c *Config = &Config{}
|
||||
@ -70,11 +77,6 @@ func LoadConfig(s string) (*Config, error) {
|
||||
err = fmt.Errorf("fatal: failed to parse; %w", err)
|
||||
}
|
||||
|
||||
envAccessToken := os.Getenv("LIFX_ACCESS_TOKEN")
|
||||
if envAccessToken != "" {
|
||||
c.AccessToken = envAccessToken
|
||||
}
|
||||
|
||||
return c, err
|
||||
}
|
||||
|
||||
@ -89,11 +91,6 @@ func LoadConfigFile(configPath string) (*Config, error) {
|
||||
err = fmt.Errorf("fatal: failed to parse %s; %w", configPath, err)
|
||||
}
|
||||
|
||||
envAccessToken := os.Getenv("LIFX_ACCESS_TOKEN")
|
||||
if envAccessToken != "" {
|
||||
c.AccessToken = envAccessToken
|
||||
}
|
||||
|
||||
return c, err
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.kill0.net/chill9/lifx-go"
|
||||
)
|
||||
@ -43,11 +42,7 @@ func Main(args []string) (int, error) {
|
||||
if config, err = LoadConfigFile(configPath); err != nil {
|
||||
return ExitFailure, err
|
||||
}
|
||||
|
||||
envAccessToken := os.Getenv("LIFX_ACCESS_TOKEN")
|
||||
if envAccessToken != "" {
|
||||
config.AccessToken = envAccessToken
|
||||
}
|
||||
config.MergeWithEnv()
|
||||
|
||||
if err = config.Validate(); err != nil {
|
||||
return ExitFailure, fmt.Errorf("fatal: %s", err)
|
||||
|
@ -24,12 +24,13 @@ func VersionCmd(args CmdArgs) (int, error) {
|
||||
if GitCommit != "" {
|
||||
fmt.Fprintf(&b, " revision: %s\n", GitCommit)
|
||||
}
|
||||
|
||||
if BuildDate != "" {
|
||||
fmt.Fprintf(&b, " build date: %s\n", BuildDate)
|
||||
}
|
||||
|
||||
fmt.Fprintf(&b, " go version: %s\n", runtime.Version())
|
||||
fmt.Fprintf(&b, " platform: %s\n", runtime.GOOS+"/"+runtime.GOARCH)
|
||||
fmt.Fprintf(&b, " platform: %s/%s\n", runtime.GOOS, runtime.GOARCH)
|
||||
|
||||
fmt.Print(b.String())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user