rush_sync_server/commands/history/
command.rs1use crate::commands::command::Command;
2use crate::core::prelude::*;
3
4#[derive(Debug)]
5pub struct HistoryCommand;
6
7impl Command for HistoryCommand {
8 fn name(&self) -> &'static str {
9 "history"
10 }
11
12 fn description(&self) -> &'static str {
13 "Manage command history"
14 }
15
16 fn matches(&self, command: &str) -> bool {
17 command.trim().starts_with("history")
18 }
19
20 fn execute_sync(&self, args: &[&str]) -> Result<String> {
21 use crate::core::constants::{SIG_CLEAR_HISTORY, SIG_CONFIRM_PREFIX};
22 match args.first() {
23 Some(&"-c" | &"--clear") => {
24 let msg = get_command_translation("system.commands.history.confirm_clear", &[]);
25 Ok(format!(
26 "{}{}{}",
27 SIG_CONFIRM_PREFIX, SIG_CLEAR_HISTORY, msg
28 ))
29 }
30
31 Some(&"--force-clear" | &"-fc") => Ok(SIG_CLEAR_HISTORY.to_string()),
32
33 Some(&"-h" | &"--help") => {
34 Ok(get_command_translation("system.commands.history.help", &[]))
35 }
36
37 _ => Ok(get_command_translation(
38 "system.commands.history.usage",
39 &[],
40 )),
41 }
42 }
43
44 fn priority(&self) -> u8 {
45 60
46 }
47}