rush_sync_server/commands/history/
command.rs

1use 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        match args.first() {
22            // ✅ NEU: Bestätigungssystem für -c/--clear
23            Some(&"-c" | &"--clear") => {
24                let msg = get_command_translation("system.commands.history.confirm_clear", &[]);
25                Ok(format!("__CONFIRM:__CLEAR_HISTORY__{}", msg))
26            }
27
28            // ✅ NEU: --force für direktes Löschen ohne Bestätigung
29            Some(&"--force-clear" | &"-fc") => Ok("__CLEAR_HISTORY__".to_string()),
30
31            Some(&"-h" | &"--help") => {
32                Ok(get_command_translation("system.commands.history.help", &[]))
33            }
34
35            _ => Ok(get_command_translation(
36                "system.commands.history.usage",
37                &[],
38            )),
39        }
40    }
41
42    fn priority(&self) -> u8 {
43        60
44    }
45}