Refactor the repl loop

This commit is contained in:
Yehuda Katz
2019-05-16 14:43:36 -07:00
parent 34a866df99
commit 98ab5e63fc
8 changed files with 243 additions and 163 deletions

View File

@ -39,11 +39,12 @@ crate fn print_items(items: &[Item]) -> String {
}
impl Item {
crate fn name(&self) -> &str {
crate fn name(&self) -> Result<&str, ShellError> {
match self {
Item::Quoted(s) => s,
Item::Bare(s) => s,
Item::Boolean(_) | Item::Int(_) => unimplemented!(),
Item::Quoted(s) => Ok(s),
Item::Bare(s) => Ok(s),
Item::Boolean(i) => Err(ShellError::string(format!("{} is not a valid command", i))),
Item::Int(i) => Err(ShellError::string(format!("{} is not a valid command", i))),
}
}
}