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;
|
||||
|
||||
fn main() {
|
||||
let commands: Vec<&str> = vec![
|
||||
"ls -l",
|
||||
" amogus",
|
||||
"lol ",
|
||||
" fozafoazngin",
|
||||
"amogus ",
|
||||
"je suis fade up la",
|
||||
" la c'est le bos final ",
|
||||
];
|
||||
let mut buffer = String::new();
|
||||
let mut result_bytes_read: io::Result<usize> = Ok(1);
|
||||
|
||||
let commands_iter = commands.iter();
|
||||
for command in commands_iter {
|
||||
println!("{:?}", parser::parse(&String::from(*command)));
|
||||
while result_bytes_read.unwrap() != 0 {
|
||||
buffer.clear();
|
||||
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