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
**/*.rs.bk
**/*.rs.bk
**/*.swp

View File

@@ -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),
}
}