config from env and log to file

This commit is contained in:
Aleksandr Trushkin
2024-02-26 13:32:24 +03:00
parent fd29ef6ff8
commit 5bcccd8aa7
3 changed files with 65 additions and 10 deletions

View File

@ -64,6 +64,10 @@ func setupDI() cli.BeforeFunc {
}
cfgpath := cmd.String("config")
if cfgpath == "" {
return errors.New("no config path provided")
}
debugLevel := cmd.Bool("verbose")
jsonFormat := cmd.Bool("json")
@ -96,9 +100,12 @@ func setupCLI() *cli.Command {
Version: fmt.Sprintf("%s (%s) %s", rooteway.Version(), rooteway.Commit(), rooteway.BuildTime()),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "config",
Usage: "path to config in TOML format",
Value: "config.toml",
Name: "config",
Usage: "path to config in TOML format",
Value: "config.toml",
Sources: cli.NewValueSourceChain(
cli.EnvVar("EWAY_CONFIG"),
),
TakesFile: true,
},
&cli.BoolFlag{