Compare commits

..

2 commits

Author SHA1 Message Date
62b2dd8065 README : ajout case 2024-04-12 10:25:38 +02:00
bb31375d25 command_builder : suppression fonction argv inutile 2024-04-12 10:23:21 +02:00
3 changed files with 4 additions and 8 deletions

View file

@ -17,3 +17,4 @@ I want to learn Rust and see how much effort I can put into making an interopera
- [ ] `type` - [ ] `type`
- [ ] Command-line flags - [ ] Command-line flags
- [ ] PS1 - [ ] PS1
- [ ] Execute code from a file

View file

@ -7,13 +7,8 @@ pub struct CommandBuilder {
} }
impl CommandBuilder { impl CommandBuilder {
pub fn new() -> Self { pub fn new(argv: Vec<String>) -> Self {
Self { argv: Vec::new() } Self { argv }
}
pub fn argv(&mut self, argv: Vec<String>) -> &Self {
self.argv = argv;
self
} }
pub fn build(&self) -> Box<dyn Command> { pub fn build(&self) -> Box<dyn Command> {

View file

@ -5,7 +5,7 @@ pub fn parse_command_line(line: String) -> Option<CommandSequence> {
let argv: Vec<String> = line.split_whitespace().map(|s| s.to_string()).collect(); let argv: Vec<String> = line.split_whitespace().map(|s| s.to_string()).collect();
if !argv.is_empty() { if !argv.is_empty() {
let command = CommandBuilder::new().argv(argv).build(); let command = CommandBuilder::new(argv).build();
Some(CommandSequence::new(command)) Some(CommandSequence::new(command))
} else { } else {
None None