RoadSign/pkg/cmd/rdc/main.go

49 lines
1.2 KiB
Go
Raw Normal View History

2023-12-10 04:30:34 +00:00
package main
import (
"os"
roadsign "code.smartsheep.studio/goatworks/roadsign/pkg"
2024-01-25 16:00:07 +00:00
"code.smartsheep.studio/goatworks/roadsign/pkg/cmd/rdc/conn"
"code.smartsheep.studio/goatworks/roadsign/pkg/cmd/rdc/deploy"
2023-12-10 04:30:34 +00:00
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"github.com/urfave/cli/v2"
)
func init() {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout})
}
func main() {
// Configure settings
viper.AddConfigPath("$HOME")
viper.SetConfigName(".roadsignrc")
2024-01-24 16:09:39 +00:00
viper.SetConfigType("toml")
2023-12-10 04:30:34 +00:00
// Load settings
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
viper.SafeWriteConfig()
viper.ReadInConfig()
} else {
log.Panic().Err(err).Msg("An error occurred when loading settings.")
}
}
// Configure CLI
app := &cli.App{
Name: "RoadSign CLI",
Version: roadsign.AppVersion,
2023-12-10 04:43:47 +00:00
Suggest: true,
2023-12-10 06:52:00 +00:00
Commands: append(append([]*cli.Command{}, conn.CliCommands...), deploy.DeployCommands...),
2023-12-10 04:30:34 +00:00
}
// Run CLI
if err := app.Run(os.Args); err != nil {
log.Fatal().Err(err).Msg("An error occurred when running cli.")
}
}