Skip to content

Commit

Permalink
handle EOF correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
CheatCod committed Jun 19, 2024
1 parent 84d9752 commit b981e37
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/command_console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@ pub fn init(app_state: AppState) {
loop {
let app_state = app_state.clone();
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
let buf_size = std::io::stdin().read_line(&mut input).unwrap();
if buf_size == 0 {
println!("EOF");
break;
}
let input_tokens = input.split_whitespace().collect::<Vec<&str>>();
match input_tokens.first() {
Some(&"di") => {
// send input tokens without the first element
handle_docker_command(&input_tokens[1..], app_state).await;
}
_ => {
println!("Unknown command");
println!("Unknown command: {}", input);
continue;
}
}
Expand Down

0 comments on commit b981e37

Please sign in to comment.