src : la séquence de commandes est optionelle
This commit is contained in:
parent
557f196fe9
commit
3a2e788c3c
2 changed files with 14 additions and 11 deletions
|
@ -13,14 +13,14 @@ pub fn run() {
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
print_prompt();
|
print_prompt();
|
||||||
|
|
||||||
let user_input = get_user_input();
|
let user_input = get_user_input();
|
||||||
|
|
||||||
if user_input.is_some() {
|
if user_input.is_some() {
|
||||||
let user_input = user_input.unwrap();
|
let command_sequence = parse_command_line(user_input.unwrap());
|
||||||
let command_sequence = parse_command_line(user_input);
|
|
||||||
|
|
||||||
current_exit_code = command_sequence.spawn();
|
if command_sequence.is_some() {
|
||||||
|
current_exit_code = command_sequence.unwrap().spawn();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
println!();
|
println!();
|
||||||
exit(¤t_exit_code);
|
exit(¤t_exit_code);
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
use crate::command::{CommandSequence, UnixProgram};
|
use crate::command::{CommandSequence, UnixProgram};
|
||||||
|
|
||||||
pub fn parse_command_line(line: String) -> CommandSequence {
|
pub fn parse_command_line(line: String) -> Option<CommandSequence> {
|
||||||
let /*mut*/ command_sequence = CommandSequence::new();
|
let argv: Vec<String> = line.split_whitespace().map(|s| s.to_string()).collect();
|
||||||
|
|
||||||
let argv = line.split_whitespace().map(|s| s.to_string()).collect();
|
if !argv.is_empty() {
|
||||||
let _command = UnixProgram::new().argv(argv);
|
let _command = UnixProgram::new().argv(argv);
|
||||||
// command_sequence.add(command);
|
let command_sequence = CommandSequence::new();
|
||||||
|
// command_sequence.add(_command);
|
||||||
command_sequence
|
Some(command_sequence)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue