diff --git a/src/clap.rs b/src/clap.rs index 68c2cca0..cea782cd 100644 --- a/src/clap.rs +++ b/src/clap.rs @@ -22,6 +22,10 @@ fn version() -> String { pub struct Args { #[command(subcommand)] pub command: Option, + + /// Path to the config file + #[arg(short, long, value_name = "PATH")] + pub config: Option, } #[derive(Subcommand)] diff --git a/src/main.rs b/src/main.rs index 3af475d9..ed7a7ccf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,10 +55,10 @@ static GLOBAL: Jemalloc = Jemalloc; async fn main() { let cli = clap::parse(); - let path = + let path = cli.config.unwrap_or_else(|| { Env::var("CONDUIT_CONFIG") .expect("The config path must either be set via the -c/--config flag or the CONDUIT_CONFIG env var. Example: /etc/conduit.toml") - ; + }); match cli.command { Some(Commands::GenerateConfig) => {