Browse Source

refactoring: simplify main loop match break and continue arms

main
fdai7451 2 years ago
parent
commit
d74949a0d4
  1. 16
      src/main.rs

16
src/main.rs

@ -31,9 +31,7 @@ fn main() -> Result<()> {
match readline {
Ok(line) => match interpret(line, &mut config, ctrlc_recv.clone()) {
Ok(_) => prompt.style = config.prompt_style.clone(),
Err(ShellError::EmptyLine) => {
continue;
}
Err(ShellError::EmptyLine) => continue,
Err(ShellError::NotFound(cmd)) => {
eprintln!("{}: command not found", cmd.get_program().to_string_lossy())
}
@ -43,16 +41,10 @@ fn main() -> Result<()> {
Err(ShellError::MalformedArgs(args)) => {
eprintln!("Malformed arguments: {}", args)
}
Err(ShellError::Interrupt) => {
continue;
}
Err(ShellError::Interrupt) => continue,
},
Err(ReadlineError::Interrupted) => {
continue;
}
Err(ReadlineError::Eof) => {
break;
}
Err(ReadlineError::Interrupted) => continue,
Err(ReadlineError::Eof) => break,
Err(err) => {
eprintln!("Error: {:?}", err);
break;

Loading…
Cancel
Save