21 lines
407 B
Rust
21 lines
407 B
Rust
use std::io::Write;
|
|
use std::io::{stdin, stdout};
|
|
|
|
pub fn print_prompt() {
|
|
print!("$ ");
|
|
stdout().flush().unwrap();
|
|
}
|
|
|
|
pub fn get_user_input() -> Option<String> {
|
|
let mut user_input = String::new();
|
|
|
|
let bytes_read = stdin()
|
|
.read_line(&mut user_input)
|
|
.expect("error reading user input");
|
|
|
|
if bytes_read == 0 {
|
|
None
|
|
} else {
|
|
Some(user_input)
|
|
}
|
|
}
|