Mercurial > templog
diff rust/src/main.rs @ 635:4424a8b30f9c rust
config crate wants everything to be lower case
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 22 Sep 2019 22:06:46 +0800 |
parents | a5721c02d3ee |
children | a9f353f488d0 |
line wrap: on
line diff
--- a/rust/src/main.rs Sun Sep 22 20:35:40 2019 +0800 +++ b/rust/src/main.rs Sun Sep 22 22:06:46 2019 +0800 @@ -12,13 +12,16 @@ mod types; mod params; -use crate::config::Config; use riker::actors::*; use structopt::StructOpt; -fn run(cf: Config, nowait: bool, testmode: bool) { +use types::TemplogError; + +fn run(conf_file: &str, nowait: bool, testmode: bool) -> Result<(), TemplogError> { + + let cf = config::Config::load(conf_file)?; let sys = ActorSystem::new().unwrap(); let props = Props::new_args(params::ParamWaiter::new, cf.clone()); @@ -34,6 +37,7 @@ let props = Props::new_args(fridge::Fridge::new_actor, (cf.clone(), nowait)); sys.actor_of(props, "fridge").unwrap(); + Ok(()) } #[derive(Debug, StructOpt)] @@ -58,9 +62,13 @@ #[structopt(long)] nowait: bool, - /// Print default config (customise in local.conf) + /// Print default config (customise in local.toml) #[structopt(long)] defconf: bool, + + /// Config file + #[structopt(short = "c", long, default_value = "local.toml")] + config: String, } fn handle_args() -> Opt { @@ -68,7 +76,7 @@ if args.defconf { println!("Default configuration:\n{}\n\n{}", - "(custom options go in local.conf)", + "(custom options go in local.toml)", config::Config::default_toml()); std::process::exit(0); } @@ -103,7 +111,8 @@ info!("wort-templog"); debug!("debug mode"); - let config = config::Config::load().unwrap(); - - run(config, args.nowait, args.test); + let r = run(&args.config, args.nowait, args.test); + if let Err(e) = r { + println!("Error running: {}", e); + } }