generated from ElnuDev/rust-project
Add demo eat command
This commit is contained in:
parent
4371a3e5f1
commit
1e7ddc475e
2 changed files with 9 additions and 2 deletions
|
@ -1,2 +1,3 @@
|
|||
"Bob sat on the bench."
|
||||
"Bob" "Good morning!"
|
||||
eat "potato"
|
|
@ -33,7 +33,10 @@ pub enum Command {
|
|||
Say {
|
||||
name: Option<String>,
|
||||
text: String,
|
||||
}
|
||||
},
|
||||
Eat {
|
||||
food: String,
|
||||
},
|
||||
}
|
||||
|
||||
use Command::*;
|
||||
|
@ -124,6 +127,9 @@ pub fn parse_file(file_path: &str) -> Vec<Command> {
|
|||
name: Some(name.to_owned()),
|
||||
text: text.to_owned(),
|
||||
},
|
||||
[Keyword(keyword), Str(food)] if keyword.eq("eat") => Eat {
|
||||
food: food.to_owned(),
|
||||
},
|
||||
_ => panic!("Unknown command {}", describe_line(&line)),
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue