diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index b40ebb65..a689701a 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -405,7 +405,7 @@ const DEPRECATED_KEYS: &[&str; 9] = &[ impl Config { /// Initialize config - pub fn new(path: Option) -> Result { + pub fn new(path: &Option) -> Result { let raw_config = if let Some(config_file_env) = Env::var("CONDUIT_CONFIG") { Figment::new() .merge(Toml::file(config_file_env).nested()) diff --git a/src/main/clap.rs b/src/main/clap.rs index 6ce164f5..e82fea16 100644 --- a/src/main/clap.rs +++ b/src/main/clap.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use clap::Parser; +use conduit::{Config, Result}; /// Commandline arguments #[derive(Parser, Debug)] @@ -15,4 +16,13 @@ pub(crate) struct Args { /// Parse commandline arguments into structured data #[must_use] -pub(crate) fn parse() -> Args { Args::parse() } +pub(super) fn parse() -> Args { Args::parse() } + +/// Synthesize any command line options with configuration file options. +pub(crate) fn update(config: &mut Config, args: &Args) -> Result<()> { + // Indicate the admin console should be spawned automatically if the + // configuration file hasn't already. + config.admin_console_automatic |= args.console.unwrap_or(false); + + Ok(()) +} diff --git a/src/main/main.rs b/src/main/main.rs index 959e8610..b13e117d 100644 --- a/src/main/main.rs +++ b/src/main/main.rs @@ -33,7 +33,7 @@ fn main() -> Result<(), Error> { .build() .expect("built runtime"); - let server: Arc = Server::build(args, Some(runtime.handle()))?; + let server: Arc = Server::build(&args, Some(runtime.handle()))?; runtime.spawn(signal::signal(server.clone())); runtime.block_on(async_main(&server))?; diff --git a/src/main/server.rs b/src/main/server.rs index 73c06f0c..b1cd6936 100644 --- a/src/main/server.rs +++ b/src/main/server.rs @@ -21,8 +21,9 @@ pub(crate) struct Server { } impl Server { - pub(crate) fn build(args: Args, runtime: Option<&runtime::Handle>) -> Result, Error> { - let config = Config::new(args.config)?; + pub(crate) fn build(args: &Args, runtime: Option<&runtime::Handle>) -> Result, Error> { + let mut config = Config::new(&args.config)?; + crate::clap::update(&mut config, args)?; #[cfg(feature = "sentry_telemetry")] let sentry_guard = crate::sentry::init(&config);