feat: b5-doctor-cmd — batch 5 upstream parity

This commit is contained in:
YeonGyu-Kim
2026-04-07 14:51:12 +09:00
parent 65f4c3ad82
commit 506ff55e53
2 changed files with 375 additions and 12 deletions

View File

@@ -1188,6 +1188,9 @@ pub enum SlashCommand {
AddDir {
path: Option<String>,
},
History {
count: Option<String>,
},
Unknown(String),
}
@@ -1421,6 +1424,9 @@ pub fn validate_slash_command_input(
"tag" => SlashCommand::Tag { label: remainder },
"output-style" => SlashCommand::OutputStyle { style: remainder },
"add-dir" => SlashCommand::AddDir { path: remainder },
"history" => SlashCommand::History {
count: optional_single_arg(command, &args, "[count]")?,
},
other => SlashCommand::Unknown(other.to_string()),
}))
}
@@ -3942,6 +3948,7 @@ pub fn handle_slash_command(
| SlashCommand::Tag { .. }
| SlashCommand::OutputStyle { .. }
| SlashCommand::AddDir { .. }
| SlashCommand::History { .. }
| SlashCommand::Unknown(_) => None,
}
}
@@ -4256,6 +4263,47 @@ mod tests {
);
}
#[test]
fn parses_history_command_without_count() {
// given
let input = "/history";
// when
let parsed = SlashCommand::parse(input);
// then
assert_eq!(parsed, Ok(Some(SlashCommand::History { count: None })));
}
#[test]
fn parses_history_command_with_numeric_count() {
// given
let input = "/history 25";
// when
let parsed = SlashCommand::parse(input);
// then
assert_eq!(
parsed,
Ok(Some(SlashCommand::History {
count: Some("25".to_string())
}))
);
}
#[test]
fn rejects_history_with_extra_arguments() {
// given
let input = "/history 25 extra";
// when
let error = parse_error_message(input);
// then
assert!(error.contains("Usage: /history [count]"));
}
#[test]
fn rejects_unexpected_arguments_for_no_arg_commands() {
// given