From 8dfd21ed430e9407880a5fc640b3351ccf34db5c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Apr 2021 19:20:53 +0200 Subject: Refactor into server-client architecture using protobuf Signed-off-by: Matthias Beyer --- src/cli.rs | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'src/cli.rs') diff --git a/src/cli.rs b/src/cli.rs index 9098cfe..61399f7 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -3,21 +3,34 @@ use clap::Arg; use clap::crate_authors; use clap::crate_version; -pub fn app<'a>() -> App<'a, 'a> { +pub fn server_app<'a>() -> App<'a, 'a> { + App::new("fss") + .author(crate_authors!()) + .version(crate_version!()) + .about("Filesystemsearch") + + .arg(self::common::arg_server_addr()) + .arg(self::common::arg_server_port()) +} + +pub fn client_app<'a>() -> App<'a, 'a> { App::new("fss") .author(crate_authors!()) .version(crate_version!()) .about("Filesystemsearch") + .arg(self::common::arg_server_addr()) + .arg(self::common::arg_server_port()) + .subcommand(App::new("index") .version(crate_version!()) .about("Index a file") .arg(Arg::with_name("file") .required(true) - .multiple(true) + .multiple(false) .value_name("FILE") - .help("Index these files") + .help("Index this file") ) ) @@ -33,4 +46,22 @@ pub fn app<'a>() -> App<'a, 'a> { ) } +mod common { + use clap::Arg; + pub fn arg_server_addr<'a, 'b>() -> Arg<'a, 'b> { + Arg::with_name("server_addr") + .required(false) + .multiple(false) + .value_name("ADDR") + .help("The address of the server") + } + + pub fn arg_server_port<'a, 'b>() -> Arg<'a, 'b> { + Arg::with_name("server_port") + .required(false) + .multiple(false) + .value_name("PORT") + .help("The port of the server") + } +} -- cgit v1.2.3