From 6d1a4b22180145222b6f4e2f5f690d4a126899a8 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Thu, 6 Aug 2020 17:22:40 -0700 Subject: [PATCH] Load config after initializing the Terminal (#848) --- zebrad/src/application.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/zebrad/src/application.rs b/zebrad/src/application.rs index 606acaa38..9e13d2c09 100644 --- a/zebrad/src/application.rs +++ b/zebrad/src/application.rs @@ -106,6 +106,17 @@ impl Application for ZebradApp { let mut components = self.framework_components(command)?; + // Load config *after* framework components so that we can + // report an error to the terminal if it occurs. + let config = command + .config_path() + .map(|path| self.load_config(&path)) + .transpose()? + .unwrap_or_default(); + + let config = command.process_config(config)?; + self.config = Some(config); + let cfg_ref = self .config .as_ref() @@ -135,16 +146,6 @@ impl Application for ZebradApp { /// Load this application's configuration and initialize its components. fn init(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> { - // Load configuration - let config = command - .config_path() - .map(|path| self.load_config(&path)) - .transpose()? - .unwrap_or_default(); - - let config = command.process_config(config)?; - self.config = Some(config); - // Create and register components with the application. // We do this first to calculate a proper dependency ordering before // application configuration is processed