Compare commits
2 commits
3fd8e3289d
...
62b2dd8065
Author | SHA1 | Date | |
---|---|---|---|
62b2dd8065 | |||
bb31375d25 |
3 changed files with 4 additions and 8 deletions
|
@ -17,3 +17,4 @@ I want to learn Rust and see how much effort I can put into making an interopera
|
|||
- [ ] `type`
|
||||
- [ ] Command-line flags
|
||||
- [ ] PS1
|
||||
- [ ] Execute code from a file
|
||||
|
|
|
@ -7,13 +7,8 @@ pub struct CommandBuilder {
|
|||
}
|
||||
|
||||
impl CommandBuilder {
|
||||
pub fn new() -> Self {
|
||||
Self { argv: Vec::new() }
|
||||
}
|
||||
|
||||
pub fn argv(&mut self, argv: Vec<String>) -> &Self {
|
||||
self.argv = argv;
|
||||
self
|
||||
pub fn new(argv: Vec<String>) -> Self {
|
||||
Self { argv }
|
||||
}
|
||||
|
||||
pub fn build(&self) -> Box<dyn Command> {
|
||||
|
|
|
@ -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();
|
||||
|
||||
if !argv.is_empty() {
|
||||
let command = CommandBuilder::new().argv(argv).build();
|
||||
let command = CommandBuilder::new(argv).build();
|
||||
Some(CommandSequence::new(command))
|
||||
} else {
|
||||
None
|
||||
|
|
Loading…
Reference in a new issue