Use a better method to reload command presets

This commit is contained in:
NI
2020-03-12 21:18:08 +08:00
parent b2210ce2b6
commit 1009cd4284
12 changed files with 206 additions and 374 deletions

View File

@@ -72,9 +72,7 @@ func (a Application) run(
) (bool, error) {
var err error
loaderName, c, cErr := cLoader(
a.logger.Context("Configuration"),
commands.Reconfigure)
loaderName, c, cErr := cLoader(a.logger.Context("Configuration"))
if cErr != nil {
a.logger.Error("\"%s\" loader cannot load configuration: %s",
@@ -83,6 +81,16 @@ func (a Application) run(
return false, cErr
}
// Allowing command to alter presets
c.Presets, err = commands.Reconfigure(c.Presets)
if err != nil {
a.logger.Error("Unable to reconfigure presets: %s", err)
return false, err
}
// Verify all configuration
err = c.Verify()
if err != nil {