pick 'settings.toml' by default

This commit is contained in:
Marc Planard 2023-06-05 11:59:10 +02:00
parent 12ceb6f69b
commit f20838e022
2 changed files with 5 additions and 8 deletions

View File

@ -6,7 +6,6 @@ pub type LJResult<T> = Result<T, Box<dyn std::error::Error>>;
#[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}")
},

View File

@ -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)?;