add commandline arg to specify a conduwuit config file
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
aec7097cd3
commit
d52f03414e
2 changed files with 20 additions and 4 deletions
21
src/main.rs
21
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<String>,
|
||||
}
|
||||
|
||||
#[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())
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue