osdb/src/main.rs

34 lines
901 B
Rust
Raw Normal View History

use osdb::branding::startup_msg;
use osdb::cli::read_input;
use osdb::error_display::OSDBError as _;
2025-05-04 14:22:19 +02:00
use osdb::parser::parse;
2025-05-01 19:24:18 +02:00
fn main() {
let mut rl = rustyline::DefaultEditor::new().expect("failed to create stdin reader");
println!("{}", startup_msg());
'main: while let Some(input) = read_input(&mut rl) {
2025-05-04 14:22:19 +02:00
let file = String::from("<stdin>");
2025-05-04 14:22:19 +02:00
match parse(file.clone(), input.clone()) {
Ok(cmds) => {
for cmd in cmds {
let result = cmd.execute();
if result.should_exit {
break 'main;
}
println!("{}", result.display());
}
}
Err(errs) => {
for err in errs {
err.display(&file, &input)
}
}
2025-05-01 21:00:28 +02:00
}
}
println!("Good-bye");
2025-05-01 21:00:28 +02:00
}