Skip to content
Snippets Groups Projects
Commit 1f657c8e authored by Benjamin Elliott's avatar Benjamin Elliott
Browse files

Avoid using _unused

Use the result information to catch bad commands before running them
parent 22231418
No related branches found
No related tags found
No related merge requests found
......@@ -6,16 +6,20 @@ use command::*;
pub fn repl() {
let mut input = String::new();
let _unused = io::stdin().read_line(&mut input);
let out_wrap = run(input.trim().split_whitespace().collect::<Vec<&str>>());
if out_wrap.is_some() {
let out = out_wrap.unwrap();
if out.stdout.is_empty() {
println!("{}",out.stderr.trim());
} else {
println!("{}",out.stdout.trim());
match io::stdin().read_line(&mut input) {
Ok(n) => {
let out_wrap = run(input.trim().split_whitespace().collect::<Vec<&str>>());
if out_wrap.is_some() {
let out = out_wrap.unwrap();
if out.stdout.is_empty() {
println!("{}",out.stderr.trim());
} else {
println!("{}",out.stdout.trim());
}
} else {
println!("{} is not a valid command", input.trim());
}
}
} else {
println!("{} is not a valid command", input.trim());
}
Err(error) => println!("Line Read Error: {}", error)
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment