diff --git a/src/gopherbridge.rs b/src/gopherbridge.rs deleted file mode 100644 index b2160fb..0000000 --- a/src/gopherbridge.rs +++ /dev/null @@ -1,2 +0,0 @@ -//! # Gopherbridge - A Bridge to display content form different sources in gopher -//! This module lists all sub modules diff --git a/src/main.rs b/src/main.rs index afd2312..39b6946 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,33 @@ extern crate clap; -use clap::{App, Arg}; +use clap::{App, Arg, ArgMatches}; +/** + * Initiates an instance of the gopherbridge server and + * starts listening for connections on the given port. + */ fn main() { - let matches = App::new("gopherbridge") + let matches = parse_command_line(); + let pluginlist = matches.value_of("PLUGIN"); + let port = matches.value_of("PORT"); + + match 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), + } +} + +/** + * Defines the command line parameters passed to the server and creates the + * server lines + */ +fn parse_command_line<'a>() -> ArgMatches<'a> { + 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") @@ -27,20 +51,7 @@ fn main() { .short("p") .long("port") .help("Specifies the port the server listens on. Default is 70") - .takes_value(false), + .takes_value(true), ) - .get_matches(); - - let pluginlist = matches.value_of("PLUGIN"); - let port = matches.value_of("PORT"); - - match 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), - } + .get_matches() }