Skip to content
Draft
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
8 changes: 4 additions & 4 deletions parser/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum Command<'a> {
Nominate(Result<nominate::NominateCommand, Error<'a>>),
Prioritize(Result<prioritize::PrioritizeCommand, Error<'a>>),
Second(Result<second::SecondCommand, Error<'a>>),
Shortcut(Result<shortcut::ShortcutCommand, Error<'a>>),
Review(Result<shortcut::ReviewCommand, Error<'a>>),
Close(Result<close::CloseCommand, Error<'a>>),
Note(Result<note::NoteCommand, Error<'a>>),
Concern(Result<concern::ConcernCommand, Error<'a>>),
Expand Down Expand Up @@ -125,8 +125,8 @@ impl<'a> Input<'a> {
&original_tokenizer,
));
success.extend(parse_single_command(
shortcut::ShortcutCommand::parse,
Command::Shortcut,
shortcut::ReviewCommand::parse,
Command::Review,
&original_tokenizer,
));
success.extend(parse_single_command(
Expand Down Expand Up @@ -210,7 +210,7 @@ impl<'a> Command<'a> {
Command::Nominate(r) => r.is_ok(),
Command::Prioritize(r) => r.is_ok(),
Command::Second(r) => r.is_ok(),
Command::Shortcut(r) => r.is_ok(),
Command::Review(r) => r.is_ok(),
Command::Close(r) => r.is_ok(),
Command::Note(r) => r.is_ok(),
Command::Concern(r) => r.is_ok(),
Expand Down
30 changes: 15 additions & 15 deletions parser/src/command/shortcut.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! The shortcut command parser.
//! Parser for commands handling a PR review status
//!
//! This can parse predefined shortcut input, single word commands.
//!
Expand All @@ -14,7 +14,7 @@ use std::collections::HashMap;
use std::fmt;

#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum ShortcutCommand {
pub enum ReviewCommand {
Ready,
Author,
Blocked,
Expand All @@ -31,14 +31,14 @@ impl fmt::Display for ParseError {
}
}

impl ShortcutCommand {
impl ReviewCommand {
pub fn parse<'a>(input: &mut Tokenizer<'a>) -> Result<Option<Self>, Error<'a>> {
let mut shortcuts = HashMap::new();
shortcuts.insert("ready", ShortcutCommand::Ready);
shortcuts.insert("review", ShortcutCommand::Ready);
shortcuts.insert("reviewer", ShortcutCommand::Ready);
shortcuts.insert("author", ShortcutCommand::Author);
shortcuts.insert("blocked", ShortcutCommand::Blocked);
shortcuts.insert("ready", ReviewCommand::Ready);
shortcuts.insert("review", ReviewCommand::Ready);
shortcuts.insert("reviewer", ReviewCommand::Ready);
shortcuts.insert("author", ReviewCommand::Author);
shortcuts.insert("blocked", ReviewCommand::Blocked);

let mut toks = input.clone();
if let Some(Token::Word(word)) = toks.peek_token()? {
Expand All @@ -55,32 +55,32 @@ impl ShortcutCommand {
}

#[cfg(test)]
fn parse(input: &str) -> Result<Option<ShortcutCommand>, Error<'_>> {
fn parse(input: &str) -> Result<Option<ReviewCommand>, Error<'_>> {
let mut toks = Tokenizer::new(input);
Ok(ShortcutCommand::parse(&mut toks)?)
Ok(ReviewCommand::parse(&mut toks)?)
}

#[test]
fn test_1() {
assert_eq!(parse("ready."), Ok(Some(ShortcutCommand::Ready)));
assert_eq!(parse("ready."), Ok(Some(ReviewCommand::Ready)));
}

#[test]
fn test_2() {
assert_eq!(parse("ready"), Ok(Some(ShortcutCommand::Ready)));
assert_eq!(parse("ready"), Ok(Some(ReviewCommand::Ready)));
}

#[test]
fn test_3() {
assert_eq!(parse("author"), Ok(Some(ShortcutCommand::Author)),);
assert_eq!(parse("author"), Ok(Some(ReviewCommand::Author)),);
}

#[test]
fn test_4() {
assert_eq!(parse("ready word"), Ok(Some(ShortcutCommand::Ready)));
assert_eq!(parse("ready word"), Ok(Some(ReviewCommand::Ready)));
}

#[test]
fn test_5() {
assert_eq!(parse("blocked"), Ok(Some(ShortcutCommand::Blocked)));
assert_eq!(parse("blocked"), Ok(Some(ReviewCommand::Blocked)));
}
Loading