|
|
@ -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> {
|
|
|
|
#[inline]
|
|
|
|
let what = &cdr[0];
|
|
|
|
fn add_job(to: &mut Config, cdr: &[Sexp]) -> Result<(), Error> {
|
|
|
|
let what = get_atom_string(what)?;
|
|
|
|
to.job_dirs.push(PathBuf::from(get_atom_string(&cdr[0])?));
|
|
|
|
to.job_dirs.push(PathBuf::from(what));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
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
|
|
|
|
/// Parse a single config file
|
|
|
|
pub async fn global(to: &mut Config, path: impl AsRef<Path>) -> Result<(), error::Error>
|
|
|
|
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) => {
|
|
|
|
Sexp::Atom(car) => {
|
|
|
|
if let Atom::S(car) = car {
|
|
|
|
if let Atom::S(car) = car {
|
|
|
|
match car.to_lowercase().trim() {
|
|
|
|
match car.to_lowercase().trim() {
|
|
|
|
"jobs-dir" => new_job(to, cdr),
|
|
|
|
"jobs-dir" => add_job(to, cdr),
|
|
|
|
"debug" => new_job(to, cdr),
|
|
|
|
"debug" => set_debug(to ,cdr),
|
|
|
|
"allow" => new_job(to, cdr),
|
|
|
|
"allow" => mwee(to, cdr),
|
|
|
|
"deny" => new_job(to, cdr),
|
|
|
|
"deny" => mwee(to, cdr),
|
|
|
|
_ => return Err(Error::Unknown),
|
|
|
|
_ => return Err(Error::Unknown),
|
|
|
|
}?;
|
|
|
|
}?;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|