rush_sync_server/commands/restart/
command.rs1use crate::commands::command::Command;
6use crate::core::prelude::*;
7use crate::i18n::get_command_translation;
8
9#[derive(Debug)]
10pub struct RestartCommand;
11
12impl Command for RestartCommand {
13 fn name(&self) -> &'static str {
14 "restart"
15 }
16
17 fn description(&self) -> &'static str {
18 "Restart the application"
19 }
20
21 fn matches(&self, command: &str) -> bool {
22 crate::matches_exact!(command, "restart" | "reboot" | "reset")
23 }
24
25 fn execute_sync(&self, args: &[&str]) -> Result<String> {
26 match args.first() {
27 Some(&"--help" | &"-h") => {
28 Ok(get_command_translation("system.commands.restart.help", &[]))
29 }
30 Some(&"--force" | &"-f") => Ok("__RESTART_FORCE__".to_string()),
31 None => {
32 let msg = get_command_translation("system.commands.restart.confirm", &[]);
33 Ok(format!("__CONFIRM_RESTART__{}", msg))
34 }
35 _ => Ok(get_command_translation(
36 "system.commands.restart.unknown",
37 &[],
38 )),
39 }
40 }
41
42 fn priority(&self) -> u8 {
43 90 }
45}