refactor: pull things into own files, have a library

This commit is contained in:
Khaïs COLIN 2025-05-02 20:35:45 +02:00
parent 4848f2be2f
commit ee23572983
7 changed files with 176 additions and 166 deletions

18
src/cli.rs Normal file
View 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)
}
}