From 674b999a4e1979f7452ead7bd3856fa5ec949d77 Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Sat, 7 Sep 2019 14:46:14 -0400 Subject: help flag --- src/main.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 1e7bd63..103cbc6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,11 @@ +use std::env; use std::fs; +use std::process; use serde::{Deserialize, Serialize}; use serde_yaml; const VERS: &str = "v0.1"; -const OUT_PATH: &str = "/var/www/htdocs/tilde.json"; const CONF_PATH: &str = "instistats.yml"; #[derive(Debug, Deserialize, Serialize)] @@ -30,7 +31,17 @@ fn main() { println!("instistats {}", VERS); println!("(c) 2019 Ben Morrison - ISC License"); println!(); - println!("Path: {}", OUT_PATH); + let args = env::args().collect::>(); + let out_path = match args[1].trim() { + "-h" | "--help" => { + println!("The only argument should be the path to save the tilde.json file.\nEx: /var/www/htdocs/tilde.json"); + process::exit(0); + } + out_path => { + println!("Output Location: {}", out_path); + out_path + } + }; println!(); let conf = fs::read_to_string(CONF_PATH).expect("Could not read config file"); -- cgit 1.4.1-2-gfad0