remove logger from cli, default config path
This commit is contained in:
parent
d82f4b7c0a
commit
141a20461f
|
@ -4,38 +4,30 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.ewintr.nl/go-kit/log"
|
||||
"git.ewintr.nl/gte/cmd/cli/command"
|
||||
"git.ewintr.nl/gte/internal/configuration"
|
||||
)
|
||||
|
||||
func main() {
|
||||
loglevel := log.LogLevel("error")
|
||||
if os.Getenv("GTE_LOGLEVEL") != "" {
|
||||
loglevel = log.LogLevel(os.Getenv("GTE_LOGLEVEL"))
|
||||
}
|
||||
logger := log.New(os.Stdout).WithField("cmd", "cli")
|
||||
logger.SetLogLevel(loglevel)
|
||||
|
||||
configPath := "/home/erik/.config/gte/gte.conf"
|
||||
configPath := "./gte.conf"
|
||||
if os.Getenv("GTE_CONFIG") != "" {
|
||||
configPath = os.Getenv("GTE_CONFIG")
|
||||
}
|
||||
configFile, err := os.Open(configPath)
|
||||
if err != nil {
|
||||
logger.WithErr(err).Error("could not open config file")
|
||||
fmt.Println(err, "could not open config file")
|
||||
os.Exit(1)
|
||||
}
|
||||
config := configuration.New(configFile)
|
||||
|
||||
cmd, err := command.Parse(os.Args[1:], config)
|
||||
if err != nil {
|
||||
logger.WithErr(err).Error("could not initialize command")
|
||||
fmt.Println(err, "could not initialize command")
|
||||
os.Exit(1)
|
||||
}
|
||||
result, err := cmd.Do()
|
||||
if err != nil {
|
||||
logger.WithErr(err).Error("could perform command")
|
||||
fmt.Println(err, "could not perform command")
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("%s\n", result.Message)
|
||||
|
|
Loading…
Reference in New Issue