diff --git a/DIFFERENCES.md b/DIFFERENCES.md index 8a85b396..48deae2d 100644 --- a/DIFFERENCES.md +++ b/DIFFERENCES.md @@ -79,4 +79,5 @@ - Make `CONDUIT_CONFIG` optional, relevant for container users that configure only by environment variables and no longer need to set `CONDUIT_CONFIG` to an empty string. - Config option to change Conduit's behaviour of homeserver key fetching (`query_trusted_key_servers_first`). This option sets whether conduwuit will query trusted notary key servers first before the individual homeserver(s), or vice versa. - Implement database flush and cleanup Conduit operations when using RocksDB -- Implement legacy Matrix `/v1/` media endpoints that some clients and servers may still call \ No newline at end of file +- Implement legacy Matrix `/v1/` media endpoints that some clients and servers may still call +- Commandline argument to specify the path to a config file \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 262fdf87..8e44134f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,13 +53,18 @@ use tracing_subscriber::{prelude::*, EnvFilter}; #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; -#[derive(Parser)] +#[derive(Parser, Debug)] #[clap(version, about, long_about = None)] -struct Args; +struct Args { + #[arg(short, long)] + /// Optional argument to the path of a conduwuit config TOML file + config: Option, +} #[tokio::main] async fn main() { - Args::parse(); + let args = Args::parse(); + // Initialize config let raw_config = if Env::var("CONDUIT_CONFIG").is_some() { Figment::new() @@ -71,6 +76,16 @@ async fn main() { .nested(), ) .merge(Env::prefixed("CONDUIT_").global()) + } else if args.config.is_some() { + Figment::new() + .merge( + Toml::file(args.config.expect( + "conduwuit config commandline argument was specified, but appears to be invalid. This should be \ + set to the path of a valid TOML file.", + )) + .nested(), + ) + .merge(Env::prefixed("CONDUIT_").global()) } else { Figment::new().merge(Env::prefixed("CONDUIT_").global()) };