From a8329cf2a502dbf96f2a139bac94b8f8469dca09 Mon Sep 17 00:00:00 2001 From: Jali Date: Sun, 2 Jun 2019 22:00:58 +0200 Subject: [PATCH] Added test code for command lines --- .gitignore | 3 ++- src/main.rs | 65 ++++++++++++++++++++++++++++------------------------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index f0e3bca..079b535 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target -**/*.rs.bk \ No newline at end of file +**/*.rs.bk +**/*.swp diff --git a/src/main.rs b/src/main.rs index 4946da8..afd2312 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,41 +1,46 @@ extern crate clap; -use clap::{Arg, App}; + +use clap::{App, Arg}; fn main() { let matches = App::new("gopherbridge") - .version("0.1") - .author("jali@orca-central.de") - .about("a simple modular gopher server, that pushes converted web-content to a client") - .arg(Arg::with_name("FORGROUND") - .short("f") - .long("foreground") - .help("Keeps the service in the foreground") - .takes_value(false)) - .arg(Arg::with_name("PLUGIN") - .short("l") - .long("plugins") - .value_name("PLUGINLIST") - .takes_value(true) - .index(1)) - .arg(Arg::with_name("PORT") - .short("p") - .long("port") - .help("Specifies the port the server listens on. Default is 70") - .takes_value(false)) - .get_matches(); + .version("0.1") + .author("jali@orca-central.de") + .about("a simple modular gopher server, that pushes converted web-content to a client") + .arg( + Arg::with_name("FORGROUND") + .short("f") + .long("foreground") + .help("Keeps the service in the foreground") + .takes_value(false), + ) + .arg( + Arg::with_name("PLUGIN") + .short("l") + .long("plugins") + .value_name("PLUGINLIST") + .takes_value(true) + .index(1), + ) + .arg( + Arg::with_name("PORT") + .short("p") + .long("port") + .help("Specifies the port the server listens on. Default is 70") + .takes_value(false), + ) + .get_matches(); let pluginlist = matches.value_of("PLUGIN"); let port = matches.value_of("PORT"); - match pluginlist { - None => println!("No plugin list"), - Some => println!("Selected Plugins: {}",Some(pluginlist)); - } - match port { - None => println!("Running on default port"), - Some => println!("Port is {}",Some(port)) + None => println!("Default port 70 used"), + Some(p) => println!("Using port {}", p), } - println!("{}",port); -} + match pluginlist { + None => println!("No plugins given"), + Some(p) => println!("Loading the following plugins: {}", p), + } +}