From 5901992d80a6a326a482e8633c9c51441141077d Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Mon, 16 Jan 2023 21:46:37 +0000 Subject: [PATCH] cli 0.1.16 dont install periphery from crates by default --- Cargo.lock | 2 +- cli/Cargo.toml | 2 +- cli/src/helpers.rs | 47 +++++++++++++++++++++++----------------------- cli/src/main.rs | 6 ++++++ 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9312932e9..82983286a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1472,7 +1472,7 @@ dependencies = [ [[package]] name = "monitor_cli" -version = "0.1.15" +version = "0.1.16" dependencies = [ "async_timing_util", "clap", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index c583e8a24..4db8a7ea1 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -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" diff --git a/cli/src/helpers.rs b/cli/src/helpers.rs index aa8e97bdb..7fdb430be 100644 --- a/cli/src/helpers.rs +++ b/cli/src/helpers.rs @@ -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::("yes").unwrap_or(&false); + let install = *sub_matches.get_one::("install").unwrap_or(&false); + let config_path = sub_matches .get_one::("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::("yes").unwrap_or(&false); + let install = *sub_matches.get_one::("install").unwrap_or(&false); + let config_path = sub_matches .get_one::("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() + ) + } +} diff --git a/cli/src/main.rs b/cli/src/main.rs index 74a626925..c60afef99 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -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 "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 "specify the file path to use for config. default is ~/.monitor/periphery.config.toml") .required(false)