From 497814fc174f73f46b0ae47ae1a9b16e6b864686 Mon Sep 17 00:00:00 2001 From: Gabriel Viganotti Date: Tue, 26 Mar 2024 16:46:27 -0300 Subject: [PATCH] refactor(cli): moving binary target related files onto src/bin dir --- sn_cli/Cargo.toml | 4 +-- sn_cli/src/{lib => }/acc_packet.rs | 0 .../{lib => }/acc_packet/change_tracking.rs | 0 sn_cli/src/{ => bin}/main.rs | 21 +++++------ sn_cli/src/{ => bin}/subcommands/files.rs | 0 sn_cli/src/{ => bin}/subcommands/folders.rs | 0 sn_cli/src/{cli.rs => bin/subcommands/mod.rs} | 29 ++++++++++++++- sn_cli/src/{ => bin}/subcommands/register.rs | 0 sn_cli/src/{ => bin}/subcommands/wallet.rs | 1 + .../src/{ => bin}/subcommands/wallet/audit.rs | 0 .../{ => bin}/subcommands/wallet/helpers.rs | 0 .../subcommands/wallet/hot_wallet.rs | 0 .../{ => bin}/subcommands/wallet/wo_wallet.rs | 0 sn_cli/src/{lib => }/files.rs | 0 sn_cli/src/{lib => }/files/chunk_manager.rs | 0 sn_cli/src/{lib => }/files/download.rs | 0 sn_cli/src/{lib => }/files/estimate.rs | 0 .../src/{lib => }/files/iterative_uploader.rs | 0 sn_cli/src/{lib => }/files/upload.rs | 0 sn_cli/src/{lib => }/lib.rs | 0 sn_cli/src/subcommands.rs | 36 ------------------- 21 files changed, 40 insertions(+), 51 deletions(-) rename sn_cli/src/{lib => }/acc_packet.rs (100%) rename sn_cli/src/{lib => }/acc_packet/change_tracking.rs (100%) rename sn_cli/src/{ => bin}/main.rs (95%) rename sn_cli/src/{ => bin}/subcommands/files.rs (100%) rename sn_cli/src/{ => bin}/subcommands/folders.rs (100%) rename sn_cli/src/{cli.rs => bin/subcommands/mod.rs} (69%) rename sn_cli/src/{ => bin}/subcommands/register.rs (100%) rename sn_cli/src/{ => bin}/subcommands/wallet.rs (99%) rename sn_cli/src/{ => bin}/subcommands/wallet/audit.rs (100%) rename sn_cli/src/{ => bin}/subcommands/wallet/helpers.rs (100%) rename sn_cli/src/{ => bin}/subcommands/wallet/hot_wallet.rs (100%) rename sn_cli/src/{ => bin}/subcommands/wallet/wo_wallet.rs (100%) rename sn_cli/src/{lib => }/files.rs (100%) rename sn_cli/src/{lib => }/files/chunk_manager.rs (100%) rename sn_cli/src/{lib => }/files/download.rs (100%) rename sn_cli/src/{lib => }/files/estimate.rs (100%) rename sn_cli/src/{lib => }/files/iterative_uploader.rs (100%) rename sn_cli/src/{lib => }/files/upload.rs (100%) rename sn_cli/src/{lib => }/lib.rs (100%) delete mode 100644 sn_cli/src/subcommands.rs diff --git a/sn_cli/Cargo.toml b/sn_cli/Cargo.toml index 44bf0b8fc9..8c1849e9a6 100644 --- a/sn_cli/Cargo.toml +++ b/sn_cli/Cargo.toml @@ -11,11 +11,11 @@ repository = "https://github.com/maidsafe/safe_network" version = "0.89.85" [[bin]] -path="src/main.rs" +path="src/bin/main.rs" name="safe" [lib] -path="src/lib/lib.rs" +path="src/lib.rs" name="autonomi" [[bench]] diff --git a/sn_cli/src/lib/acc_packet.rs b/sn_cli/src/acc_packet.rs similarity index 100% rename from sn_cli/src/lib/acc_packet.rs rename to sn_cli/src/acc_packet.rs diff --git a/sn_cli/src/lib/acc_packet/change_tracking.rs b/sn_cli/src/acc_packet/change_tracking.rs similarity index 100% rename from sn_cli/src/lib/acc_packet/change_tracking.rs rename to sn_cli/src/acc_packet/change_tracking.rs diff --git a/sn_cli/src/main.rs b/sn_cli/src/bin/main.rs similarity index 95% rename from sn_cli/src/main.rs rename to sn_cli/src/bin/main.rs index ff145eda17..13ce887081 100644 --- a/sn_cli/src/main.rs +++ b/sn_cli/src/bin/main.rs @@ -9,22 +9,19 @@ #[macro_use] extern crate tracing; -mod cli; mod subcommands; -use crate::{ - cli::Opt, - subcommands::{ - files::files_cmds, - folders::folders_cmds, - register::register_cmds, - wallet::{ - hot_wallet::{wallet_cmds, wallet_cmds_without_client, WalletCmds}, - wo_wallet::{wo_wallet_cmds, wo_wallet_cmds_without_client, WatchOnlyWalletCmds}, - }, - SubCmd, +use subcommands::{ + files::files_cmds, + folders::folders_cmds, + register::register_cmds, + wallet::{ + hot_wallet::{wallet_cmds, wallet_cmds_without_client, WalletCmds}, + wo_wallet::{wo_wallet_cmds, wo_wallet_cmds_without_client, WatchOnlyWalletCmds}, }, + Opt, SubCmd, }; + use bls::SecretKey; use clap::Parser; use color_eyre::Result; diff --git a/sn_cli/src/subcommands/files.rs b/sn_cli/src/bin/subcommands/files.rs similarity index 100% rename from sn_cli/src/subcommands/files.rs rename to sn_cli/src/bin/subcommands/files.rs diff --git a/sn_cli/src/subcommands/folders.rs b/sn_cli/src/bin/subcommands/folders.rs similarity index 100% rename from sn_cli/src/subcommands/folders.rs rename to sn_cli/src/bin/subcommands/folders.rs diff --git a/sn_cli/src/cli.rs b/sn_cli/src/bin/subcommands/mod.rs similarity index 69% rename from sn_cli/src/cli.rs rename to sn_cli/src/bin/subcommands/mod.rs index 779c5e0030..1076061f8b 100644 --- a/sn_cli/src/cli.rs +++ b/sn_cli/src/bin/subcommands/mod.rs @@ -6,8 +6,13 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use crate::subcommands::SubCmd; +pub(crate) mod files; +pub(crate) mod folders; +pub(crate) mod register; +pub(crate) mod wallet; + use clap::Parser; +use clap::Subcommand; use color_eyre::Result; use sn_logging::{LogFormat, LogOutputDest}; use sn_peers_acquisition::PeersArgs; @@ -57,3 +62,25 @@ pub(crate) struct Opt { #[clap(global = true, long = "no-verify", short = 'x')] pub no_verify: bool, } + +#[derive(Subcommand, Debug)] +pub(super) enum SubCmd { + #[clap(name = "wallet", subcommand)] + /// Commands for a hot-wallet management. + /// A hot-wallet holds the secret key, thus it can be used for signing transfers/transactions. + Wallet(wallet::hot_wallet::WalletCmds), + #[clap(name = "wowallet", subcommand)] + /// Commands for watch-only wallet management + /// A watch-only wallet holds only the public key, thus it cannot be used for signing + /// transfers/transactions, but only to query balances and broadcast offline signed transactions. + WatchOnlyWallet(wallet::wo_wallet::WatchOnlyWalletCmds), + #[clap(name = "files", subcommand)] + /// Commands for file management + Files(files::FilesCmds), + #[clap(name = "folders", subcommand)] + /// Commands for folders management + Folders(folders::FoldersCmds), + #[clap(name = "register", subcommand)] + /// Commands for register management + Register(register::RegisterCmds), +} diff --git a/sn_cli/src/subcommands/register.rs b/sn_cli/src/bin/subcommands/register.rs similarity index 100% rename from sn_cli/src/subcommands/register.rs rename to sn_cli/src/bin/subcommands/register.rs diff --git a/sn_cli/src/subcommands/wallet.rs b/sn_cli/src/bin/subcommands/wallet.rs similarity index 99% rename from sn_cli/src/subcommands/wallet.rs rename to sn_cli/src/bin/subcommands/wallet.rs index 9a360ee861..b8a88f036a 100644 --- a/sn_cli/src/subcommands/wallet.rs +++ b/sn_cli/src/bin/subcommands/wallet.rs @@ -5,6 +5,7 @@ // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. + mod audit; pub(crate) mod helpers; pub(crate) mod hot_wallet; diff --git a/sn_cli/src/subcommands/wallet/audit.rs b/sn_cli/src/bin/subcommands/wallet/audit.rs similarity index 100% rename from sn_cli/src/subcommands/wallet/audit.rs rename to sn_cli/src/bin/subcommands/wallet/audit.rs diff --git a/sn_cli/src/subcommands/wallet/helpers.rs b/sn_cli/src/bin/subcommands/wallet/helpers.rs similarity index 100% rename from sn_cli/src/subcommands/wallet/helpers.rs rename to sn_cli/src/bin/subcommands/wallet/helpers.rs diff --git a/sn_cli/src/subcommands/wallet/hot_wallet.rs b/sn_cli/src/bin/subcommands/wallet/hot_wallet.rs similarity index 100% rename from sn_cli/src/subcommands/wallet/hot_wallet.rs rename to sn_cli/src/bin/subcommands/wallet/hot_wallet.rs diff --git a/sn_cli/src/subcommands/wallet/wo_wallet.rs b/sn_cli/src/bin/subcommands/wallet/wo_wallet.rs similarity index 100% rename from sn_cli/src/subcommands/wallet/wo_wallet.rs rename to sn_cli/src/bin/subcommands/wallet/wo_wallet.rs diff --git a/sn_cli/src/lib/files.rs b/sn_cli/src/files.rs similarity index 100% rename from sn_cli/src/lib/files.rs rename to sn_cli/src/files.rs diff --git a/sn_cli/src/lib/files/chunk_manager.rs b/sn_cli/src/files/chunk_manager.rs similarity index 100% rename from sn_cli/src/lib/files/chunk_manager.rs rename to sn_cli/src/files/chunk_manager.rs diff --git a/sn_cli/src/lib/files/download.rs b/sn_cli/src/files/download.rs similarity index 100% rename from sn_cli/src/lib/files/download.rs rename to sn_cli/src/files/download.rs diff --git a/sn_cli/src/lib/files/estimate.rs b/sn_cli/src/files/estimate.rs similarity index 100% rename from sn_cli/src/lib/files/estimate.rs rename to sn_cli/src/files/estimate.rs diff --git a/sn_cli/src/lib/files/iterative_uploader.rs b/sn_cli/src/files/iterative_uploader.rs similarity index 100% rename from sn_cli/src/lib/files/iterative_uploader.rs rename to sn_cli/src/files/iterative_uploader.rs diff --git a/sn_cli/src/lib/files/upload.rs b/sn_cli/src/files/upload.rs similarity index 100% rename from sn_cli/src/lib/files/upload.rs rename to sn_cli/src/files/upload.rs diff --git a/sn_cli/src/lib/lib.rs b/sn_cli/src/lib.rs similarity index 100% rename from sn_cli/src/lib/lib.rs rename to sn_cli/src/lib.rs diff --git a/sn_cli/src/subcommands.rs b/sn_cli/src/subcommands.rs deleted file mode 100644 index 1b24054835..0000000000 --- a/sn_cli/src/subcommands.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2024 MaidSafe.net limited. -// -// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. -// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed -// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. Please review the Licences for the specific language governing -// permissions and limitations relating to use of the SAFE Network Software. - -pub(crate) mod files; -pub(crate) mod folders; -pub(crate) mod register; -pub(crate) mod wallet; - -use clap::Subcommand; - -#[derive(Subcommand, Debug)] -pub(super) enum SubCmd { - #[clap(name = "wallet", subcommand)] - /// Commands for a hot-wallet management. - /// A hot-wallet holds the secret key, thus it can be used for signing transfers/transactions. - Wallet(wallet::hot_wallet::WalletCmds), - #[clap(name = "wowallet", subcommand)] - /// Commands for watch-only wallet management - /// A watch-only wallet holds only the public key, thus it cannot be used for signing - /// transfers/transactions, but only to query balances and broadcast offline signed transactions. - WatchOnlyWallet(wallet::wo_wallet::WatchOnlyWalletCmds), - #[clap(name = "files", subcommand)] - /// Commands for file management - Files(files::FilesCmds), - #[clap(name = "folders", subcommand)] - /// Commands for folders management - Folders(folders::FoldersCmds), - #[clap(name = "register", subcommand)] - /// Commands for register management - Register(register::RegisterCmds), -}