Add demo eat command

main
Elnu 1 year ago
parent 4371a3e5f1
commit 1e7ddc475e

@ -1,2 +1,3 @@
"Bob sat on the bench."
"Bob" "Good morning!"
"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…
Cancel
Save