From 58b8bc1a68d624d418680c4649aaeb65affd804b Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 20 Jan 2020 10:31:18 +0000 Subject: [PATCH 1/3] lib definition in cargo.toml --- nym-client/Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nym-client/Cargo.toml b/nym-client/Cargo.toml index e2276544c9..53bfe0e9a1 100644 --- a/nym-client/Cargo.toml +++ b/nym-client/Cargo.toml @@ -7,6 +7,10 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +name = "nym_client" +path = "src/lib.rs" + [dependencies] base64 = "0.11.0" clap = "2.33.0" From 3737c535ff48e4c55747455259605681e96c0e18 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 20 Jan 2020 10:31:49 +0000 Subject: [PATCH 2/3] Moved built_info to module in separate file --- nym-client/src/built_info.rs | 2 ++ nym-client/src/lib.rs | 8 ++++++++ nym-client/src/main.rs | 5 +---- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 nym-client/src/built_info.rs create mode 100644 nym-client/src/lib.rs diff --git a/nym-client/src/built_info.rs b/nym-client/src/built_info.rs new file mode 100644 index 0000000000..d11fb6389f --- /dev/null +++ b/nym-client/src/built_info.rs @@ -0,0 +1,2 @@ +// The file has been placed there by the build script. +include!(concat!(env!("OUT_DIR"), "/built.rs")); diff --git a/nym-client/src/lib.rs b/nym-client/src/lib.rs new file mode 100644 index 0000000000..5fa9078897 --- /dev/null +++ b/nym-client/src/lib.rs @@ -0,0 +1,8 @@ +#![recursion_limit = "256"] + +pub mod built_info; +pub mod clients; +pub mod commands; +pub mod persistence; +pub mod sockets; +pub mod utils; diff --git a/nym-client/src/main.rs b/nym-client/src/main.rs index b69fa95213..0e4e7f96fc 100644 --- a/nym-client/src/main.rs +++ b/nym-client/src/main.rs @@ -5,15 +5,12 @@ use env_logger; use log::*; use std::process; +pub mod built_info; pub mod clients; mod commands; mod persistence; mod sockets; pub mod utils; -pub mod built_info { - // The file has been placed there by the build script. - include!(concat!(env!("OUT_DIR"), "/built.rs")); -} fn main() { env_logger::init(); From 32a978d93242537815a2d5b637d1fbfe665c0cbd Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 20 Jan 2020 10:32:07 +0000 Subject: [PATCH 3/3] Removed call to 'banner' from external modules --- nym-client/src/commands/init.rs | 2 -- nym-client/src/commands/tcpsocket.rs | 3 --- nym-client/src/commands/websocket.rs | 3 --- nym-client/src/main.rs | 15 ++++++++++++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/nym-client/src/commands/init.rs b/nym-client/src/commands/init.rs index ce6ee879b4..f6d675ea02 100644 --- a/nym-client/src/commands/init.rs +++ b/nym-client/src/commands/init.rs @@ -1,11 +1,9 @@ -use crate::banner; use crate::persistence::pathfinder::Pathfinder; use crate::persistence::pemstore::PemStore; use clap::ArgMatches; use crypto::identity::MixnetIdentityKeyPair; pub fn execute(matches: &ArgMatches) { - println!("{}", banner()); println!("Initialising client..."); let id = matches.value_of("id").unwrap().to_string(); // required for now diff --git a/nym-client/src/commands/tcpsocket.rs b/nym-client/src/commands/tcpsocket.rs index 97b258101e..3ed3662c7b 100644 --- a/nym-client/src/commands/tcpsocket.rs +++ b/nym-client/src/commands/tcpsocket.rs @@ -1,4 +1,3 @@ -use crate::banner; use crate::clients::{NymClient, SocketType}; use crate::persistence::pemstore; @@ -7,8 +6,6 @@ use crypto::identity::{MixnetIdentityKeyPair, MixnetIdentityPublicKey}; use std::net::ToSocketAddrs; pub fn execute(matches: &ArgMatches) { - println!("{}", banner()); - let id = matches.value_of("id").unwrap().to_string(); let port = match matches.value_of("port").unwrap_or("9001").parse::() { Ok(n) => n, diff --git a/nym-client/src/commands/websocket.rs b/nym-client/src/commands/websocket.rs index 4b27bc3455..99dbc1ecc6 100644 --- a/nym-client/src/commands/websocket.rs +++ b/nym-client/src/commands/websocket.rs @@ -1,4 +1,3 @@ -use crate::banner; use crate::clients::{NymClient, SocketType}; use crate::persistence::pemstore; @@ -7,8 +6,6 @@ use crypto::identity::{MixnetIdentityKeyPair, MixnetIdentityPublicKey}; use std::net::ToSocketAddrs; pub fn execute(matches: &ArgMatches) { - println!("{}", banner()); - let id = matches.value_of("id").unwrap().to_string(); let port = match matches.value_of("port").unwrap_or("9001").parse::() { Ok(n) => n, diff --git a/nym-client/src/main.rs b/nym-client/src/main.rs index 0e4e7f96fc..7cede69284 100644 --- a/nym-client/src/main.rs +++ b/nym-client/src/main.rs @@ -91,9 +91,18 @@ fn main() { fn execute(matches: ArgMatches) -> Result<(), String> { match matches.subcommand() { - ("init", Some(m)) => Ok(commands::init::execute(m)), - ("tcpsocket", Some(m)) => Ok(commands::tcpsocket::execute(m)), - ("websocket", Some(m)) => Ok(commands::websocket::execute(m)), + ("init", Some(m)) => { + println!("{}", banner()); + Ok(commands::init::execute(m)) + } + ("tcpsocket", Some(m)) => { + println!("{}", banner()); + Ok(commands::tcpsocket::execute(m)) + } + ("websocket", Some(m)) => { + println!("{}", banner()); + Ok(commands::websocket::execute(m)) + } _ => Err(usage()), } }