rush_sync_server/commands/log_level/
command.rs

1use super::manager::LogLevelManager;
2use crate::commands::command::Command;
3use crate::core::prelude::*;
4
5#[derive(Debug)]
6pub struct LogLevelCommand;
7
8impl Command for LogLevelCommand {
9    fn name(&self) -> &'static str {
10        "log-level"
11    }
12
13    fn description(&self) -> &'static str {
14        "Change application log level"
15    }
16
17    fn matches(&self, command: &str) -> bool {
18        let cmd = command.trim().to_lowercase();
19        cmd.starts_with("log-level")
20            || cmd.starts_with("loglevel")
21            || (cmd.starts_with("config") && cmd.contains("--log-level"))
22    }
23
24    // ✅ FIXED EXECUTE_SYNC - Proper error handling
25    fn execute_sync(&self, args: &[&str]) -> Result<String> {
26        match args.first() {
27            None => Ok(LogLevelManager::show_status()),
28            Some(&"--help" | &"-h" | &"help") => Ok(LogLevelManager::show_help_i18n()),
29            Some(&level) => LogLevelManager::set_level_persistent(level), // Direkt weiterleiten
30        }
31    }
32
33    fn priority(&self) -> u8 {
34        75
35    }
36}