src : la séquence de commandes est optionelle

This commit is contained in:
Ahurac 2024-04-10 16:43:01 +02:00
parent 557f196fe9
commit 3a2e788c3c
2 changed files with 14 additions and 11 deletions

View file

@ -13,14 +13,14 @@ pub fn run() {
loop {
print_prompt();
let user_input = get_user_input();
if user_input.is_some() {
let user_input = user_input.unwrap();
let command_sequence = parse_command_line(user_input);
let command_sequence = parse_command_line(user_input.unwrap());
current_exit_code = command_sequence.spawn();
if command_sequence.is_some() {
current_exit_code = command_sequence.unwrap().spawn();
}
} else {
println!();
exit(&current_exit_code);

View file

@ -1,11 +1,14 @@
use crate::command::{CommandSequence, UnixProgram};
pub fn parse_command_line(line: String) -> CommandSequence {
let /*mut*/ command_sequence = CommandSequence::new();
pub fn parse_command_line(line: String) -> Option<CommandSequence> {
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);
// command_sequence.add(command);
command_sequence
let command_sequence = CommandSequence::new();
// command_sequence.add(_command);
Some(command_sequence)
} else {
None
}
}