gte/cmd/cli/main.go

35 lines
681 B
Go
Raw Normal View History

2021-06-25 09:14:27 +02:00
package main
import (
"fmt"
"os"
"git.ewintr.nl/gte/cmd/cli/command"
"git.ewintr.nl/gte/internal/configuration"
)
func main() {
configPath := "./gte.conf"
2021-06-25 09:14:27 +02:00
if os.Getenv("GTE_CONFIG") != "" {
configPath = os.Getenv("GTE_CONFIG")
}
configFile, err := os.Open(configPath)
if err != nil {
fmt.Println(err, "could not open config file")
2021-06-25 09:14:27 +02:00
os.Exit(1)
}
config := configuration.New(configFile)
cmd, err := command.Parse(os.Args[1:], config)
if err != nil {
fmt.Println(err, "could not initialize command")
2021-06-25 09:14:27 +02:00
os.Exit(1)
}
result, err := cmd.Do()
if err != nil {
fmt.Println(err, "could not perform command")
2021-06-25 09:14:27 +02:00
os.Exit(1)
}
fmt.Printf("%s\n", result.Message)
}