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