mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-08 00:54:49 +08:00
feat: b5-doctor-cmd — batch 5 upstream parity
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user