Added test code for command lines
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
/target
|
/target
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
**/*.swp
|
||||||
|
|||||||
65
src/main.rs
65
src/main.rs
@@ -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),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user