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;
|
mod command;
|
||||||
use std::io::Write;
|
mod control;
|
||||||
|
mod interface;
|
||||||
fn exit() {
|
|
||||||
println!("exit");
|
|
||||||
std::process::exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut user_input = String::new();
|
control::run();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue