rash/src/parser.rs

16 lines
459 B
Rust
Raw Normal View History

2024-04-11 10:16:09 +02:00
use crate::command::command_sequence::CommandSequence;
use crate::command::unix_program::UnixProgram;
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 = UnixProgram::new(argv);
let command_sequence = CommandSequence::new(command);
Some(command_sequence)
} else {
None
}
2024-04-10 12:31:29 +02:00
}