Added test code for command lines
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
**/*.swp
|
||||
|
||||
37
src/main.rs
37
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")
|
||||
.arg(
|
||||
Arg::with_name("FORGROUND")
|
||||
.short("f")
|
||||
.long("foreground")
|
||||
.help("Keeps the service in the foreground")
|
||||
.takes_value(false))
|
||||
.arg(Arg::with_name("PLUGIN")
|
||||
.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")
|
||||
.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))
|
||||
.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))
|
||||
}
|
||||
println!("{}",port);
|
||||
None => println!("Default port 70 used"),
|
||||
Some(p) => println!("Using port {}", p),
|
||||
}
|
||||
|
||||
match pluginlist {
|
||||
None => println!("No plugins given"),
|
||||
Some(p) => println!("Loading the following plugins: {}", p),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user