diff options
author | xengineering <me@xengineering.eu> | 2024-05-12 00:03:56 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-05-12 00:03:56 +0200 |
commit | 938ab103727688b73f2d7b3ef4d9e1b1c85c6628 (patch) | |
tree | 76356b9b10efcb4c2c24ba67380c6c2613143abb | |
parent | 907bd7e63f4cf3cb01bc678e09fc5b8962afe750 (diff) | |
download | ceres-938ab103727688b73f2d7b3ef4d9e1b1c85c6628.tar ceres-938ab103727688b73f2d7b3ef4d9e1b1c85c6628.tar.zst ceres-938ab103727688b73f2d7b3ef4d9e1b1c85c6628.zip |
Group flag variables in struct
-rw-r--r-- | flags.go | 14 | ||||
-rw-r--r-- | main.go | 4 |
2 files changed, 10 insertions, 8 deletions
@@ -16,18 +16,20 @@ Usage: ceres [-h | --help] [-v | --version] [-c | --config] -e, --examples inject example recipes on startup ` -var printVersion bool -var injectExamples bool +var flags struct { + version bool + examples bool +} func init() { - flag.BoolVar(&printVersion, "version", false, "print version information") - flag.BoolVar(&printVersion, "v", false, "print version information") + flag.BoolVar(&flags.version, "version", false, "print version information") + flag.BoolVar(&flags.version, "v", false, "print version information") flag.StringVar(&config.Path, "config", "", "file path to configuration file") flag.StringVar(&config.Path, "c", "", "file path to configuration file") - flag.BoolVar(&injectExamples, "examples", false, "inject example recipes on startup") - flag.BoolVar(&injectExamples, "e", false, "inject example recipes on startup") + flag.BoolVar(&flags.examples, "examples", false, "inject example recipes on startup") + flag.BoolVar(&flags.examples, "e", false, "inject example recipes on startup") flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), help) @@ -15,7 +15,7 @@ import ( func main() { flag.Parse() - if printVersion { + if flags.version { fmt.Println(version) os.Exit(0) } @@ -38,7 +38,7 @@ func main() { defer model.DisconnectDatabase() model.MigrateDatabase(version) - if injectExamples { + if flags.examples { model.InjectExampleRecipes() log.Println("Added example recipes") } |