Ajout : lecture des commandes depuis stdin
This commit is contained in:
parent
544ca5076a
commit
675a176b77
1 changed files with 15 additions and 12 deletions
27
src/main.rs
27
src/main.rs
|
@ -1,18 +1,21 @@
|
||||||
|
use std::io;
|
||||||
|
|
||||||
mod parser;
|
mod parser;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let commands: Vec<&str> = vec![
|
let mut buffer = String::new();
|
||||||
"ls -l",
|
let mut result_bytes_read: io::Result<usize> = Ok(1);
|
||||||
" amogus",
|
|
||||||
"lol ",
|
|
||||||
" fozafoazngin",
|
|
||||||
"amogus ",
|
|
||||||
"je suis fade up la",
|
|
||||||
" la c'est le bos final ",
|
|
||||||
];
|
|
||||||
|
|
||||||
let commands_iter = commands.iter();
|
while result_bytes_read.unwrap() != 0 {
|
||||||
for command in commands_iter {
|
buffer.clear();
|
||||||
println!("{:?}", parser::parse(&String::from(*command)));
|
result_bytes_read = io::stdin().read_line(&mut buffer);
|
||||||
|
|
||||||
|
if !result_bytes_read.is_err() {
|
||||||
|
let command_vec: Vec<String> = parser::parse(&buffer);
|
||||||
|
println!("{:?}", command_vec);
|
||||||
|
} else {
|
||||||
|
eprintln!("error: invalid UTF-8 characters were read");
|
||||||
|
result_bytes_read = Ok(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue