mirror of
https://github.com/egor-white/zaprett.git
synced 2026-01-31 06:59:48 +05:00
Compare commits
4 Commits
ac35be8e57
...
6.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f29ed9de63 | ||
|
|
d58792fbfc | ||
|
|
860dc21272 | ||
|
|
277f6756bd |
@@ -30,3 +30,4 @@ panic = "abort"
|
||||
opt-level = "z"
|
||||
lto = true
|
||||
strip = true
|
||||
codegen-units = 1
|
||||
|
||||
@@ -2,19 +2,20 @@ use crate::MODULE_PATH;
|
||||
use tokio::fs;
|
||||
use tokio::fs::File;
|
||||
|
||||
pub async fn set_autostart(autostart: bool) -> Result<(), anyhow::Error> {
|
||||
pub async fn set_autostart() -> Result<(), anyhow::Error> {
|
||||
let autostart_path = MODULE_PATH.join("autostart");
|
||||
|
||||
if autostart {
|
||||
if !get_autostart() {
|
||||
File::create(autostart_path).await?;
|
||||
} else {
|
||||
fs::remove_file(autostart_path).await?;
|
||||
}
|
||||
|
||||
println!("{}", get_autostart());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_autostart() {
|
||||
let file = MODULE_PATH.join("autostart");
|
||||
println!("{}", file.exists());
|
||||
pub fn get_autostart() -> bool {
|
||||
return MODULE_PATH.join("autostart").exists();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::autostart::{get_autostart, set_autostart};
|
||||
use crate::service::{restart_service, service_status, start_service, stop_service};
|
||||
use crate::{bin_version, module_version};
|
||||
use crate::{bin_version, module_version, run_nfqws};
|
||||
use clap::Subcommand;
|
||||
use log::error;
|
||||
use crate::autostart::{get_autostart, set_autostart};
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum Command {
|
||||
@@ -19,11 +19,7 @@ pub enum Command {
|
||||
Status,
|
||||
|
||||
/// Enable or disable automatic restart
|
||||
SetAutostart {
|
||||
/// Whether to enable (true) or disable (false) autostart
|
||||
#[arg(value_parser = clap::value_parser!(bool))]
|
||||
autostart: bool,
|
||||
},
|
||||
SetAutostart,
|
||||
|
||||
/// Show whether autostart is enabled
|
||||
GetAutostart,
|
||||
@@ -33,6 +29,12 @@ pub enum Command {
|
||||
|
||||
/// Show the nfqws binary version
|
||||
BinaryVersion,
|
||||
|
||||
/// Run nfqws
|
||||
Args {
|
||||
#[arg(allow_hyphen_values=true, trailing_var_arg = true, num_args = 0..)]
|
||||
args: Vec<String>,
|
||||
},
|
||||
}
|
||||
|
||||
impl Command {
|
||||
@@ -53,14 +55,15 @@ impl Command {
|
||||
}
|
||||
);
|
||||
}
|
||||
Command::SetAutostart { autostart } => {
|
||||
if let Err(err) = set_autostart(*autostart).await {
|
||||
Command::SetAutostart => {
|
||||
if let Err(err) = set_autostart().await {
|
||||
error!("Failed to set auto start: {err}")
|
||||
}
|
||||
}
|
||||
Command::GetAutostart => get_autostart(),
|
||||
Command::GetAutostart => println!("{}", get_autostart()),
|
||||
Command::ModuleVersion => println!("{}", module_version().await?),
|
||||
Command::BinaryVersion => println!("{}", bin_version()),
|
||||
Command::Args { args } => run_nfqws(&args.join(" "))?,
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user