rash/src/parser.rs

14 lines
426 B
Rust
Raw Normal View History

2024-04-11 19:09:19 +02:00
use crate::command::command_builder::CommandBuilder;
2024-04-11 10:16:09 +02:00
use crate::command::command_sequence::CommandSequence;
2024-04-10 12:31:29 +02:00
pub fn parse_command_line(line: String) -> Option<CommandSequence> {
let argv: Vec<String> = line.split_whitespace().map(|s| s.to_string()).collect();
2024-04-10 12:31:29 +02:00
if !argv.is_empty() {
let command = CommandBuilder::new(argv).build();
2024-04-11 19:09:19 +02:00
Some(CommandSequence::new(command))
} else {
None
}
2024-04-10 12:31:29 +02:00
}