Update for recent go-flags API changes.
This commit is contained in:
parent
bec16828c5
commit
e3e8a06661
1 changed files with 10 additions and 2 deletions
12
config.go
12
config.go
|
@ -156,15 +156,16 @@ func loadConfig() (*config, []string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load additional config from file.
|
// Load additional config from file.
|
||||||
|
var configFileError error
|
||||||
parser := flags.NewParser(&cfg, flags.Default)
|
parser := flags.NewParser(&cfg, flags.Default)
|
||||||
err = parser.ParseIniFile(preCfg.ConfigFile)
|
err = flags.NewIniParser(parser).ParseFile(preCfg.ConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(*os.PathError); !ok {
|
if _, ok := err.(*os.PathError); !ok {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
parser.WriteHelp(os.Stderr)
|
parser.WriteHelp(os.Stderr)
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
log.Warnf("%v", err)
|
configFileError = err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse command line options again to ensure they take precedence.
|
// Parse command line options again to ensure they take precedence.
|
||||||
|
@ -176,6 +177,13 @@ func loadConfig() (*config, []string, error) {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warn about missing config file after the final command line parse
|
||||||
|
// succeeds. This prevents the warning on help messages and invalid
|
||||||
|
// options.
|
||||||
|
if configFileError != nil {
|
||||||
|
log.Warnf("%v", configFileError)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(jrick): Enable mainnet support again when ready.
|
// TODO(jrick): Enable mainnet support again when ready.
|
||||||
cfg.MainNet = false
|
cfg.MainNet = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue