feat: allow specifying config path via command flag

This commit is contained in:
Matthias Ahouansou 2024-04-19 21:06:58 +01:00
parent 60a2f2d011
commit 9a88386ddf
No known key found for this signature in database
2 changed files with 6 additions and 2 deletions

View File

@ -22,6 +22,10 @@ fn version() -> String {
pub struct Args {
#[command(subcommand)]
pub command: Option<Commands>,
/// Path to the config file
#[arg(short, long, value_name = "PATH")]
pub config: Option<String>,
}
#[derive(Subcommand)]

View File

@ -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) => {