gte/cmd/cli/main.go

30 lines
581 B
Go
Raw Normal View History

2021-06-25 09:14:27 +02:00
package main
import (
"fmt"
"os"
2024-09-17 07:33:26 +02:00
"go-mod.ewintr.nl/gte/cmd/cli/command"
"go-mod.ewintr.nl/gte/internal/configuration"
2021-06-25 09:14:27 +02:00
)
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)
}
2022-09-14 16:14:18 +02:00
config := configuration.NewFromFile(configFile)
2021-06-25 09:14:27 +02:00
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)
}
2021-09-04 19:47:36 +02:00
fmt.Printf("%s", cmd.Do())
2021-06-25 09:14:27 +02:00
}