Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions parser/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,18 @@ fn concern() {
);
}

#[test]
fn concern_resolve() {
let input = "@bot concern resolve this is my concern";
let mut input = Input::new(input, vec!["bot"]);
assert_eq!(
input.next(),
Some(Command::Concern(Ok(concern::ConcernCommand::Resolve {
title: "this is my concern".to_string()
})))
);
}

#[test]
fn resolve() {
let input = "@bot resolve this is my concern";
Expand Down
9 changes: 8 additions & 1 deletion parser/src/command/concern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ impl fmt::Display for ParseError {
impl ConcernCommand {
pub fn parse<'a>(input: &mut Tokenizer<'a>) -> Result<Option<Self>, Error<'a>> {
let mut toks = input.clone();
if let Some(Token::Word(action @ ("concern" | "resolve"))) = toks.peek_token()? {
if let Some(Token::Word(mut action @ ("concern" | "resolve"))) = toks.peek_token()? {
toks.next_token()?;

if action == "concern" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what is someone tries to create a concern (sentence) that starts with the word "resolve"? 😆 Well, probably a too niche of an edge-case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked jieyouxu about it and I was told "that seems somewhat... strange xD", so left it. We can always add it later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought that was even more niche, and maybe more of a "well don't do that" xD

if let Some(Token::Word(sub_action @ "resolve")) = toks.peek_token()? {
toks.next_token()?;
action = sub_action;
}
}

let title = toks.take_line()?.trim().to_string();

if title.is_empty() {
Expand Down
Loading