diff --git a/src/init.rs b/src/commands/init.rs similarity index 90% rename from src/init.rs rename to src/commands/init.rs index 53fad233d0..42e846d2dd 100644 --- a/src/init.rs +++ b/src/commands/init.rs @@ -1,6 +1,6 @@ use clap::ArgMatches; -pub fn init(matches: &ArgMatches) { +pub fn execute(matches: &ArgMatches) { println!("Running client init!"); // don't unwrap it, pass it as it is, if it's None, choose a random diff --git a/src/commands/mod.rs b/src/commands/mod.rs new file mode 100644 index 0000000000..3336430356 --- /dev/null +++ b/src/commands/mod.rs @@ -0,0 +1,3 @@ +pub mod init; +pub mod run; +pub mod socket; \ No newline at end of file diff --git a/src/run.rs b/src/commands/run.rs similarity index 98% rename from src/run.rs rename to src/commands/run.rs index a8e5ad054a..a73c82e2ad 100644 --- a/src/run.rs +++ b/src/commands/run.rs @@ -9,7 +9,7 @@ use std::time::Duration; use tokio::runtime::Runtime; use tokio::time::{interval_at, Instant}; -pub fn run(matches: &ArgMatches) { +pub fn execute(matches: &ArgMatches) { let custom_cfg = matches.value_of("customCfg"); println!( "Going to start client with custom config of: {:?}", diff --git a/src/socket.rs b/src/commands/socket.rs similarity index 94% rename from src/socket.rs rename to src/commands/socket.rs index e741b6aa51..09cc09a557 100644 --- a/src/socket.rs +++ b/src/commands/socket.rs @@ -1,6 +1,6 @@ use clap::ArgMatches; -pub fn socket(matches: &ArgMatches) { +pub fn execute(matches: &ArgMatches) { let custom_cfg = matches.value_of("customCfg"); let socket_type = match matches.value_of("socketType").unwrap() { TCP_SOCKET_TYPE => TCP_SOCKET_TYPE, diff --git a/src/main.rs b/src/main.rs index 6f554a32a7..3157b047c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,24 +2,11 @@ use clap::{App, Arg, ArgMatches, SubCommand}; use std::process; mod clients; -mod init; -mod run; -mod socket; +mod commands; const TCP_SOCKET_TYPE: &str = "tcp"; const WEBSOCKET_SOCKET_TYPE: &str = "websocket"; -fn execute(matches: ArgMatches) -> Result<(), String> { - match matches.subcommand() { - ("init", Some(m)) => Ok(init::init(m)), - ("run", Some(m)) => Ok(run::run(m)), - ("socket", Some(m)) => Ok(socket::socket(m)), - - _ => Err(String::from("Unknown command")), - } -} - -// TODO: perhaps more subcommands and/or args to distinguish between coco client and mix client fn main() { let arg_matches = App::new("Nym Client") .version("0.1.0") @@ -85,3 +72,13 @@ fn main() { process::exit(1); } } + +fn execute(matches: ArgMatches) -> Result<(), String> { + match matches.subcommand() { + ("init", Some(m)) => Ok(commands::init::execute(m)), + ("run", Some(m)) => Ok(commands::run::execute(m)), + ("socket", Some(m)) => Ok(commands::socket::execute(m)), + + _ => Err(String::from("Unknown command")), + } +} \ No newline at end of file