|
|
@ -63,27 +63,10 @@ fn main() -> Result<()> {
|
|
|
|
info!("◇ {}", s);
|
|
|
|
info!("◇ {}", s);
|
|
|
|
let tree = parse::parse(&s)?;
|
|
|
|
let tree = parse::parse(&s)?;
|
|
|
|
debug!(" {:?}", tree);
|
|
|
|
debug!(" {:?}", tree);
|
|
|
|
let parts: Vec<&str> = s.split_whitespace().collect();
|
|
|
|
shell.exec(tree)?;
|
|
|
|
|
|
|
|
// Some commands don't leave the terminal in a clean state, so we use reset
|
|
|
|
if parts.len() > 0 {
|
|
|
|
// to ensure that our input and output modes are what we expect them to be.
|
|
|
|
let cmd = parts[0].to_string();
|
|
|
|
shell.reset()?;
|
|
|
|
let args = if parts.len() > 1 {
|
|
|
|
|
|
|
|
parts[1..].to_vec()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
vec![]
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
match shell.eval(cmd.clone(), args.clone()) {
|
|
|
|
|
|
|
|
Ok(true) => debug!(" ok"),
|
|
|
|
|
|
|
|
Ok(false) => warn!(" fail"),
|
|
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
|
|
error!("▷ {} {} ● {}", cmd, args.join(" "), e);
|
|
|
|
|
|
|
|
println!("error: {}", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some commands don't leave the terminal in a clean state, so we use reset
|
|
|
|
|
|
|
|
// to ensure that our input and output modes are what we expect them to be.
|
|
|
|
|
|
|
|
shell.reset()?;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
prompt.print(&mut shell.output)?;
|
|
|
|
prompt.print(&mut shell.output)?;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|