From 432a27e8789ba554650e654695284ab770fdaea8 Mon Sep 17 00:00:00 2001 From: Louis Capitanchik <contact@louiscap.co> Date: Mon, 16 Apr 2018 16:35:53 +0100 Subject: [PATCH] Implement default CliArgs --- src/cli/cli.rs | 19 +++++++++++++++++++ src/main.rs | 12 +----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/cli/cli.rs b/src/cli/cli.rs index 578dc8c..363fa59 100644 --- a/src/cli/cli.rs +++ b/src/cli/cli.rs @@ -1,5 +1,6 @@ pub use std::path::PathBuf; pub use std::env::current_dir; +pub use std::default::Default; pub const USAGE: &'static str = " Static file swerver and api mocker for local development. @@ -54,4 +55,22 @@ impl Args { ).to_string_lossy().into_owned()) ) } +} + +impl Default for Args { + fn default() -> Self { + Args { + flag_dir: Some(""), + flag_port: Some(8000), + flag_config: None, + flag_threads: Some(32), + flag_address: Some("localhost"), + flag_help: false, + flag_quiet: false, + flag_no_index: false, + flag_upload: false, + flag_upload_path: None, + flag_license: false, + } + } } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 856fa7d..832dc77 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,18 +19,8 @@ fn main() { .unwrap_or_else(|e| e.exit()); let is_quiet = args.flag_quiet; - macro_rules! printq { - ($( $x:expr ),+) => { - { - if !is_quiet { - println!($($x),*); - } - } - } - } - if args.flag_help { - printq!("{}", cli::USAGE); + if !is_quiet { println!("{}", cli::USAGE); } process::exit(0); } -- GitLab