diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-09-07 14:46:14 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-09-07 14:46:14 -0400 |
commit | 674b999a4e1979f7452ead7bd3856fa5ec949d77 (patch) | |
tree | 1742b5eb0c5ecd410ace45546072e9094471df7b | |
parent | 194881ebf325f269891eb05c41c4bcf0baf3fed3 (diff) | |
download | instistats-674b999a4e1979f7452ead7bd3856fa5ec949d77.tar.gz |
help flag
-rw-r--r-- | src/main.rs | 15 |
1 files changed, 13 insertions, 2 deletions
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::<Vec<String>>(); + 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"); |