Skip to content

Commit e304185

Browse files
committed
Rename ShortcutCommand to ReviewCommand
The ShortcutCommand was born to handle one case (reviews) but I'd like to expand its scope to handle more convenience custom shortcuts for commands that will modify labels. However just adding more code would make things a bit confusing, so I'd first start clarifying the scope of the existing code and in subsequent patches add more shortcut commands. At a high level, I can imagine something like this: - shortcut::ReviewCommand to handle commands like `author`, `review`, `ready`, etc. - shortcut::RegressionCommand to handle future commands for quick switching label regressions (todo) - shortcut:NewCommand (and so on) Functionally this patch changes nothing, it's just renaming things.
1 parent 08781c3 commit e304185

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

parser/src/command.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub enum Command<'a> {
2323
Nominate(Result<nominate::NominateCommand, Error<'a>>),
2424
Prioritize(Result<prioritize::PrioritizeCommand, Error<'a>>),
2525
Second(Result<second::SecondCommand, Error<'a>>),
26-
Shortcut(Result<shortcut::ShortcutCommand, Error<'a>>),
26+
Review(Result<shortcut::ReviewCommand, Error<'a>>),
2727
Close(Result<close::CloseCommand, Error<'a>>),
2828
Note(Result<note::NoteCommand, Error<'a>>),
2929
Concern(Result<concern::ConcernCommand, Error<'a>>),
@@ -125,8 +125,8 @@ impl<'a> Input<'a> {
125125
&original_tokenizer,
126126
));
127127
success.extend(parse_single_command(
128-
shortcut::ShortcutCommand::parse,
129-
Command::Shortcut,
128+
shortcut::ReviewCommand::parse,
129+
Command::Review,
130130
&original_tokenizer,
131131
));
132132
success.extend(parse_single_command(
@@ -210,7 +210,7 @@ impl<'a> Command<'a> {
210210
Command::Nominate(r) => r.is_ok(),
211211
Command::Prioritize(r) => r.is_ok(),
212212
Command::Second(r) => r.is_ok(),
213-
Command::Shortcut(r) => r.is_ok(),
213+
Command::Review(r) => r.is_ok(),
214214
Command::Close(r) => r.is_ok(),
215215
Command::Note(r) => r.is_ok(),
216216
Command::Concern(r) => r.is_ok(),

parser/src/command/shortcut.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! The shortcut command parser.
1+
//! Parser for commands handling a PR review status
22
//!
33
//! This can parse predefined shortcut input, single word commands.
44
//!
@@ -14,7 +14,7 @@ use std::collections::HashMap;
1414
use std::fmt;
1515

1616
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
17-
pub enum ShortcutCommand {
17+
pub enum ReviewCommand {
1818
Ready,
1919
Author,
2020
Blocked,
@@ -31,14 +31,14 @@ impl fmt::Display for ParseError {
3131
}
3232
}
3333

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

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

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

6363
#[test]
6464
fn test_1() {
65-
assert_eq!(parse("ready."), Ok(Some(ShortcutCommand::Ready)));
65+
assert_eq!(parse("ready."), Ok(Some(ReviewCommand::Ready)));
6666
}
6767

6868
#[test]
6969
fn test_2() {
70-
assert_eq!(parse("ready"), Ok(Some(ShortcutCommand::Ready)));
70+
assert_eq!(parse("ready"), Ok(Some(ReviewCommand::Ready)));
7171
}
7272

7373
#[test]
7474
fn test_3() {
75-
assert_eq!(parse("author"), Ok(Some(ShortcutCommand::Author)),);
75+
assert_eq!(parse("author"), Ok(Some(ReviewCommand::Author)),);
7676
}
7777

7878
#[test]
7979
fn test_4() {
80-
assert_eq!(parse("ready word"), Ok(Some(ShortcutCommand::Ready)));
80+
assert_eq!(parse("ready word"), Ok(Some(ReviewCommand::Ready)));
8181
}
8282

8383
#[test]
8484
fn test_5() {
85-
assert_eq!(parse("blocked"), Ok(Some(ShortcutCommand::Blocked)));
85+
assert_eq!(parse("blocked"), Ok(Some(ReviewCommand::Blocked)));
8686
}

0 commit comments

Comments
 (0)