Added test code for command lines

This commit is contained in:
2019-06-02 22:00:58 +02:00
parent e81cda8b73
commit a8329cf2a5
2 changed files with 37 additions and 31 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
/target /target
**/*.rs.bk **/*.rs.bk
**/*.swp

View File

@@ -1,41 +1,46 @@
extern crate clap; extern crate clap;
use clap::{Arg, App};
use clap::{App, Arg};
fn main() { fn main() {
let matches = App::new("gopherbridge") let matches = App::new("gopherbridge")
.version("0.1") .version("0.1")
.author("jali@orca-central.de") .author("jali@orca-central.de")
.about("a simple modular gopher server, that pushes converted web-content to a client") .about("a simple modular gopher server, that pushes converted web-content to a client")
.arg(Arg::with_name("FORGROUND") .arg(
.short("f") Arg::with_name("FORGROUND")
.long("foreground") .short("f")
.help("Keeps the service in the foreground") .long("foreground")
.takes_value(false)) .help("Keeps the service in the foreground")
.arg(Arg::with_name("PLUGIN") .takes_value(false),
.short("l") )
.long("plugins") .arg(
.value_name("PLUGINLIST") Arg::with_name("PLUGIN")
.takes_value(true) .short("l")
.index(1)) .long("plugins")
.arg(Arg::with_name("PORT") .value_name("PLUGINLIST")
.short("p") .takes_value(true)
.long("port") .index(1),
.help("Specifies the port the server listens on. Default is 70") )
.takes_value(false)) .arg(
.get_matches(); 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 pluginlist = matches.value_of("PLUGIN");
let port = matches.value_of("PORT"); let port = matches.value_of("PORT");
match pluginlist {
None => println!("No plugin list"),
Some => println!("Selected Plugins: {}",Some(pluginlist));
}
match port { match port {
None => println!("Running on default port"), None => println!("Default port 70 used"),
Some => println!("Port is {}",Some(port)) Some(p) => println!("Using port {}", p),
} }
println!("{}",port);
}
match pluginlist {
None => println!("No plugins given"),
Some(p) => println!("Loading the following plugins: {}", p),
}
}