diff options
| author | Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io> | 2023-01-05 12:27:42 +0000 |
|---|---|---|
| committer | James Mills <james@mills.io> | 2023-01-05 12:27:42 +0000 |
| commit | f6dedea101ea5f81448aac8af30302e2e13f621f (patch) | |
| tree | f07b29abb6a87da1245b0b60bfd834d178fb5906 | |
| parent | d0727c2187290f22b498f20da2c0b6f2cee1f444 (diff) | |
fix(config): Always show config file name and abort if read fails (#46)
With this change you should always know what config tube is using.
If an explicitly requested file can not be read, then tube
will complain and exit.
This should fix issue #45
Reviewed-on: https://git.mills.io/prologic/tube/pulls/46
Co-authored-by: Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io>
Co-committed-by: Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io>
| -rw-r--r-- | main.go | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -41,14 +41,15 @@ func main() { } cfg := app.DefaultConfig() + log.Infof("Reading configuration from %s", config) err := cfg.ReadFile(config) - if err == nil { - log.Infof("reading configuration from %s", config) - } else { - if !os.IsNotExist(err) { + if err != nil { + if flag.Lookup("config").Changed { log.Fatal(err) } + log.Infof("Reading %s failed. Starting with builtin defaults.", config) } + // I'd like to add something like this here: log.Debug("Active config: %s", cfg.toJson()) a, err := app.NewApp(cfg) if err != nil { log.Fatal(err) |
