cli periphery seems to be working

This commit is contained in:
mbecker20
2023-01-05 03:16:37 +00:00
parent 243f54ec11
commit 86af789dd3
2 changed files with 21 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
use std::{
env,
fs::{self, File},
io::{Read, Write},
net::IpAddr,
@@ -272,12 +273,20 @@ pub fn gen_periphery_config(sub_matches: &ArgMatches) {
.map(|p| p.as_str())
.unwrap_or("")
.split(",")
.filter(|ip| ip.len() > 0)
.map(|ip| {
ip.parse()
.expect("given allowed ip address is not valid ip")
})
.collect::<Vec<IpAddr>>();
let repo_dir = sub_matches
.get_one::<String>("repo_dir")
.map(|p| p.as_str())
.unwrap_or("~/.monitor/repos")
.to_string()
.replace("~", env::var("HOME").unwrap().as_str());
let config = PeripheryConfig {
port,
stats_polling_rate,
@@ -344,7 +353,10 @@ pub fn start_periphery_daemon(sub_matches: &ArgMatches) {
if install_output.success() {
println!("\ninstallation finished, starting monitor periphery daemon\n")
} else {
eprintln!("\n❌ there was some {} during periphery installation ❌\n", "error".red());
eprintln!(
"\n❌ there was some {} during periphery installation ❌\n",
"error".red()
);
return;
}

View File

@@ -22,6 +22,10 @@ fn cli() -> Command {
.subcommand(
Command::new("gen_config")
.about("generate a core config file")
.arg(
arg!(--host <HOST> "the host to use with oauth redirect url, whatever host the user hits to access monitor. eg 'https://monitor.mogh.tech'")
.required(true)
)
.arg(
arg!(--path <PATH> "sets path of generated config file. default is '~/.monitor/core.config.toml'")
.required(false)
@@ -110,10 +114,6 @@ fn cli() -> Command {
.subcommand(
Command::new("gen_config")
.about("generate a periphery config file")
.arg(
arg!(--host <HOST> "the host to use with oauth redirect url, whatever host the user hits to access monitor. eg 'https://monitor.mogh.tech'")
.required(true)
)
.arg(
arg!(--path <PATH> "sets path of generated config file. default is '~/.monitor/periphery.config.toml'")
.required(false)
@@ -128,6 +128,10 @@ fn cli() -> Command {
)
.arg(
arg!(--allowed_ips <IPS> "used to only accept requests from known ips. give ips as comma seperated list, like '--allowed_ips 127.0.0.1,10.20.30.43'. default is empty, which will not block any ip.")
.required(false)
)
.arg(
arg!(--repo_dir <PATH> "if running in container, this should be '/repos'. default is ~/.monitor/repos").required(false)
)
)
.subcommand(