refactor: pull things into own files, have a library
This commit is contained in:
parent
4848f2be2f
commit
ee23572983
7 changed files with 176 additions and 166 deletions
18
src/cli.rs
Normal file
18
src/cli.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
pub fn read_input() -> Option<String> {
|
||||
use std::io::{BufRead, Write};
|
||||
|
||||
print!("osdb > ");
|
||||
std::io::stdout().flush().expect("failed to flush stdout");
|
||||
|
||||
let mut input = String::new();
|
||||
let len = std::io::stdin()
|
||||
.lock()
|
||||
.read_line(&mut input)
|
||||
.expect("failed to read input from stdin");
|
||||
|
||||
if len == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(input)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue