infra to synthesize program options with config options

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-22 21:16:46 +00:00
parent 59efabbbc2
commit 2fb43dd38d
4 changed files with 16 additions and 5 deletions

View file

@ -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(())
}