main : modularisation
This commit is contained in:
parent
c55268e0a9
commit
2bf03f0662
1 changed files with 4 additions and 28 deletions
32
src/main.rs
32
src/main.rs
|
@ -1,31 +1,7 @@
|
|||
use std::io;
|
||||
use std::io::Write;
|
||||
|
||||
fn exit() {
|
||||
println!("exit");
|
||||
std::process::exit(0);
|
||||
}
|
||||
mod command;
|
||||
mod control;
|
||||
mod interface;
|
||||
|
||||
fn main() {
|
||||
let mut user_input = String::new();
|
||||
let mut bytes_read;
|
||||
|
||||
loop {
|
||||
print!("$ ");
|
||||
io::stdout().flush().unwrap();
|
||||
|
||||
user_input.clear();
|
||||
bytes_read = io::stdin()
|
||||
.read_line(&mut user_input)
|
||||
.expect("error reading user input");
|
||||
|
||||
if bytes_read == 0 {
|
||||
println!();
|
||||
exit();
|
||||
} else {
|
||||
let user_input = user_input.trim();
|
||||
|
||||
println!("{}", user_input);
|
||||
}
|
||||
}
|
||||
control::run();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue