|
|
|
@ -63,27 +63,10 @@ fn main() -> Result<()> {
|
|
|
|
|
info!("◇ {}", s);
|
|
|
|
|
let tree = parse::parse(&s)?;
|
|
|
|
|
debug!(" {:?}", tree);
|
|
|
|
|
let parts: Vec<&str> = s.split_whitespace().collect();
|
|
|
|
|
|
|
|
|
|
if parts.len() > 0 {
|
|
|
|
|
let cmd = parts[0].to_string();
|
|
|
|
|
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()?;
|
|
|
|
|
}
|
|
|
|
|
shell.exec(tree)?;
|
|
|
|
|
// 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)?;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|