cli 0.1.16 dont install periphery from crates by default

This commit is contained in:
mbecker20
2023-01-16 21:46:37 +00:00
parent 13e8ad93e2
commit 5901992d80
4 changed files with 31 additions and 26 deletions

2
Cargo.lock generated
View File

@@ -1472,7 +1472,7 @@ dependencies = [
[[package]]
name = "monitor_cli"
version = "0.1.15"
version = "0.1.16"
dependencies = [
"async_timing_util",
"clap",

View File

@@ -1,6 +1,6 @@
[package]
name = "monitor_cli"
version = "0.1.15"
version = "0.1.16"
edition = "2021"
authors = ["MoghTech"]
description = "monitor cli | tools to setup monitor system"

View File

@@ -337,6 +337,8 @@ pub fn gen_periphery_config(sub_matches: &ArgMatches) {
pub fn start_periphery_systemd(sub_matches: &ArgMatches) {
let skip_enter = *sub_matches.get_one::<bool>("yes").unwrap_or(&false);
let install = *sub_matches.get_one::<bool>("install").unwrap_or(&false);
let config_path = sub_matches
.get_one::<String>("config-path")
.map(|p| p.as_str())
@@ -366,18 +368,8 @@ pub fn start_periphery_systemd(sub_matches: &ArgMatches) {
}
}
println!("\ninstalling periphery binary...\n");
let install_output = run_command_pipe_to_terminal(&format!("cargo install {PERIPHERY_CRATE}"));
if install_output.success() {
println!("\ninstallation finished, starting monitor periphery...\n")
} else {
eprintln!(
"\n❌ there was some {} during periphery installation ❌\n",
"error".red()
);
return;
if install {
install_periphery_from_crates_io();
}
gen_periphery_service_file(&config_path);
@@ -402,6 +394,8 @@ pub fn start_periphery_systemd(sub_matches: &ArgMatches) {
pub fn start_periphery_daemon(sub_matches: &ArgMatches) {
let skip_enter = *sub_matches.get_one::<bool>("yes").unwrap_or(&false);
let install = *sub_matches.get_one::<bool>("install").unwrap_or(&false);
let config_path = sub_matches
.get_one::<String>("config-path")
.map(|p| p.as_str())
@@ -445,18 +439,8 @@ pub fn start_periphery_daemon(sub_matches: &ArgMatches) {
}
}
println!("\ninstalling periphery binary...\n");
let install_output = run_command_pipe_to_terminal(&format!("cargo install {PERIPHERY_CRATE}"));
if install_output.success() {
println!("\ninstallation finished, starting monitor periphery daemon\n")
} else {
eprintln!(
"\n❌ there was some {} during periphery installation ❌\n",
"error".red()
);
return;
if install {
install_periphery_from_crates_io();
}
let command = format!("if pgrep periphery; then pkill periphery; fi && periphery --daemon --config-path {config_path} --stdout {stdout} --stderr {stderr}");
@@ -610,3 +594,18 @@ TimeoutStartSec=0
WantedBy=default.target"
)
}
fn install_periphery_from_crates_io() {
println!("\ninstalling periphery binary...\n");
let install_output = run_command_pipe_to_terminal(&format!("cargo install {PERIPHERY_CRATE}"));
if install_output.success() {
println!("\ninstallation finished, starting monitor periphery daemon\n");
} else {
panic!(
"\n❌ there was some {} during periphery installation ❌\n",
"error".red()
)
}
}

View File

@@ -153,6 +153,9 @@ fn cli() -> Command {
.arg(
arg!(--yes "used in scripts to skip 'enter to continue' step")
)
.arg(
arg!(--install "specify this to install periphery from crates.io")
)
.arg(
arg!(--config-path <PATH> "specify the file path to use for config. default is ~/.monitor/periphery.config.toml")
.required(false)
@@ -164,6 +167,9 @@ fn cli() -> Command {
.arg(
arg!(--yes "used in scripts to skip 'enter to continue' step")
)
.arg(
arg!(--install "specify this to install periphery from crates.io")
)
.arg(
arg!(--config-path <PATH> "specify the file path to use for config. default is ~/.monitor/periphery.config.toml")
.required(false)