|
|
|
@ -17,14 +17,36 @@ fn get_atom_string<'a>(maybe_atom: &'a Sexp) -> Result<&'a String, Error>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn new_job(to: &mut Config, cdr: &[Sexp]) -> Result<(), Error> {
|
|
|
|
|
let what = &cdr[0];
|
|
|
|
|
let what = get_atom_string(what)?;
|
|
|
|
|
to.job_dirs.push(PathBuf::from(what));
|
|
|
|
|
#[inline]
|
|
|
|
|
fn add_job(to: &mut Config, cdr: &[Sexp]) -> Result<(), Error> {
|
|
|
|
|
to.job_dirs.push(PathBuf::from(get_atom_string(&cdr[0])?));
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
fn set_debug(to: &mut Config, cdr: &[Sexp]) -> Result<(), Error> {
|
|
|
|
|
if !to.debug {
|
|
|
|
|
let debug = get_atom_string(&cdr[0])?;
|
|
|
|
|
to.debug = match debug.to_lowercase().trim() {
|
|
|
|
|
"t" => true,
|
|
|
|
|
"nil" => false,
|
|
|
|
|
_ => return Err(Error::Unknown)
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
// Should be debug is set.
|
|
|
|
|
return Err(Error::Unknown)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
fn mwee(to: &mut Config, cdr: &[Sexp]) -> Result<(), Error> {
|
|
|
|
|
println!("{:?}", cdr);
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Parse a single config file
|
|
|
|
|
pub async fn global(to: &mut Config, path: impl AsRef<Path>) -> Result<(), error::Error>
|
|
|
|
|
{
|
|
|
|
@ -48,10 +70,10 @@ pub async fn global(to: &mut Config, path: impl AsRef<Path>) -> Result<(), error
|
|
|
|
|
Sexp::Atom(car) => {
|
|
|
|
|
if let Atom::S(car) = car {
|
|
|
|
|
match car.to_lowercase().trim() {
|
|
|
|
|
"jobs-dir" => new_job(to, cdr),
|
|
|
|
|
"debug" => new_job(to, cdr),
|
|
|
|
|
"allow" => new_job(to, cdr),
|
|
|
|
|
"deny" => new_job(to, cdr),
|
|
|
|
|
"jobs-dir" => add_job(to, cdr),
|
|
|
|
|
"debug" => set_debug(to ,cdr),
|
|
|
|
|
"allow" => mwee(to, cdr),
|
|
|
|
|
"deny" => mwee(to, cdr),
|
|
|
|
|
_ => return Err(Error::Unknown),
|
|
|
|
|
}?;
|
|
|
|
|
} else {
|
|
|
|
|