pick 'settings.toml' by default
This commit is contained in:
parent
12ceb6f69b
commit
f20838e022
@ -6,7 +6,6 @@ pub type LJResult<T> = Result<T, Box<dyn std::error::Error>>;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum LJError {
|
pub enum LJError {
|
||||||
ConfigFileMissing,
|
|
||||||
RedisConnect(RedisError),
|
RedisConnect(RedisError),
|
||||||
HeliosDeviceMissing
|
HeliosDeviceMissing
|
||||||
}
|
}
|
||||||
@ -16,10 +15,6 @@ impl fmt::Display for LJError {
|
|||||||
use LJError::*;
|
use LJError::*;
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
ConfigFileMissing => {
|
|
||||||
write!(f, "first argument must be a TOML config file \
|
|
||||||
(see copyme.Settings.toml)")
|
|
||||||
},
|
|
||||||
RedisConnect(err) => {
|
RedisConnect(err) => {
|
||||||
write!(f, "unable to connect to redis server: {err}")
|
write!(f, "unable to connect to redis server: {err}")
|
||||||
},
|
},
|
||||||
|
@ -23,6 +23,7 @@ use errors::{LJError,LJResult};
|
|||||||
use point::Point;
|
use point::Point;
|
||||||
use transformer::{Transformers,Translate,Replicate};
|
use transformer::{Transformers,Translate,Replicate};
|
||||||
|
|
||||||
|
const DEFAULT_CONF_FILE : &str = "settings.toml";
|
||||||
const CENTER : (f32,f32) = (2000.0, 2000.0);
|
const CENTER : (f32,f32) = (2000.0, 2000.0);
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
@ -35,9 +36,10 @@ pub fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_all() -> LJResult<()> {
|
fn run_all() -> LJResult<()> {
|
||||||
let Some(filename) = std::env::args().nth(1) else {
|
let filename = std::env::args().nth(1).unwrap_or_else(|| {
|
||||||
return Err(Box::new(LJError::ConfigFileMissing));
|
DEFAULT_CONF_FILE.to_string()
|
||||||
};
|
});
|
||||||
|
|
||||||
let config = Conf::new(&filename)?;
|
let config = Conf::new(&filename)?;
|
||||||
let mut rs = RedisCtrl::new(&config.redis_url)?;
|
let mut rs = RedisCtrl::new(&config.redis_url)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user