diff --git a/src/errors.rs b/src/errors.rs index bb6900e..45363e5 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -6,7 +6,6 @@ pub type LJResult = Result>; #[derive(Debug)] pub enum LJError { - ConfigFileMissing, RedisConnect(RedisError), HeliosDeviceMissing } @@ -16,10 +15,6 @@ impl fmt::Display for LJError { use LJError::*; match self { - ConfigFileMissing => { - write!(f, "first argument must be a TOML config file \ - (see copyme.Settings.toml)") - }, RedisConnect(err) => { write!(f, "unable to connect to redis server: {err}") }, diff --git a/src/main.rs b/src/main.rs index 498ff2a..3b76adb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ use errors::{LJError,LJResult}; use point::Point; use transformer::{Transformers,Translate,Replicate}; +const DEFAULT_CONF_FILE : &str = "settings.toml"; const CENTER : (f32,f32) = (2000.0, 2000.0); pub fn main() { @@ -35,9 +36,10 @@ pub fn main() { } fn run_all() -> LJResult<()> { - let Some(filename) = std::env::args().nth(1) else { - return Err(Box::new(LJError::ConfigFileMissing)); - }; + let filename = std::env::args().nth(1).unwrap_or_else(|| { + DEFAULT_CONF_FILE.to_string() + }); + let config = Conf::new(&filename)?; let mut rs = RedisCtrl::new(&config.redis_url)?;