diff --git a/cargo-near/src/abi_command/abi.rs b/cargo-near/src/commands/abi_command/abi.rs similarity index 100% rename from cargo-near/src/abi_command/abi.rs rename to cargo-near/src/commands/abi_command/abi.rs diff --git a/cargo-near/src/abi_command/mod.rs b/cargo-near/src/commands/abi_command/mod.rs similarity index 100% rename from cargo-near/src/abi_command/mod.rs rename to cargo-near/src/commands/abi_command/mod.rs diff --git a/cargo-near/src/build_command/build.rs b/cargo-near/src/commands/build_command/build.rs similarity index 97% rename from cargo-near/src/build_command/build.rs rename to cargo-near/src/commands/build_command/build.rs index 65bdafc4..7fe0a634 100644 --- a/cargo-near/src/build_command/build.rs +++ b/cargo-near/src/commands/build_command/build.rs @@ -4,8 +4,8 @@ use near_abi::BuildInfo; use sha2::{Digest, Sha256}; use std::io::BufRead; -use crate::abi_command::abi; -use crate::abi_command::abi::{AbiCompression, AbiFormat, AbiResult}; +use crate::commands::abi_command::abi; +use crate::commands::abi_command::abi::{AbiCompression, AbiFormat, AbiResult}; use crate::common::ColorPreference; use crate::types::{manifest::CargoManifestPath, metadata::CrateMetadata}; use crate::util; diff --git a/cargo-near/src/build_command/mod.rs b/cargo-near/src/commands/build_command/mod.rs similarity index 100% rename from cargo-near/src/build_command/mod.rs rename to cargo-near/src/commands/build_command/mod.rs diff --git a/cargo-near/src/commands/mod.rs b/cargo-near/src/commands/mod.rs new file mode 100644 index 00000000..7f58522c --- /dev/null +++ b/cargo-near/src/commands/mod.rs @@ -0,0 +1,20 @@ +use strum::{EnumDiscriminants, EnumIter, EnumMessage}; + +pub mod abi_command; +pub mod build_command; + +#[derive(Debug, EnumDiscriminants, Clone, interactive_clap::InteractiveClap)] +#[interactive_clap(context = near_cli_rs::GlobalContext)] +#[strum_discriminants(derive(EnumMessage, EnumIter))] +#[interactive_clap(disable_back)] +/// What are you up to? (select one of the options with the up-down arrows on your keyboard and press Enter) +pub enum NearCommand { + #[strum_discriminants(strum( + message = "build - Build a NEAR contract and optionally embed ABI" + ))] + /// Build a NEAR contract and optionally embed ABI + Build(self::build_command::BuildCommand), + #[strum_discriminants(strum(message = "abi - Generates ABI for the contract"))] + /// Generates ABI for the contract + Abi(self::abi_command::AbiCommand), +} diff --git a/cargo-near/src/lib.rs b/cargo-near/src/lib.rs index df58210f..d8acc010 100644 --- a/cargo-near/src/lib.rs +++ b/cargo-near/src/lib.rs @@ -1,8 +1,7 @@ pub use near_cli_rs::CliResult; use strum::{EnumDiscriminants, EnumIter, EnumMessage}; -pub mod abi_command; -pub mod build_command; +pub mod commands; mod common; pub mod types; mod util; @@ -11,7 +10,7 @@ mod util; #[interactive_clap(context = near_cli_rs::GlobalContext)] pub struct Cmd { #[interactive_clap(subcommand)] - opts: Opts, + pub opts: Opts, } #[derive(Debug, EnumDiscriminants, Clone, interactive_clap::InteractiveClap)] @@ -29,21 +28,5 @@ pub enum Opts { #[interactive_clap(context = near_cli_rs::GlobalContext)] pub struct NearArgs { #[interactive_clap(subcommand)] - pub cmd: NearCommand, -} - -#[derive(Debug, EnumDiscriminants, Clone, interactive_clap::InteractiveClap)] -#[interactive_clap(context = near_cli_rs::GlobalContext)] -#[strum_discriminants(derive(EnumMessage, EnumIter))] -#[interactive_clap(disable_back)] -/// What are you up to? (select one of the options with the up-down arrows on your keyboard and press Enter) -pub enum NearCommand { - #[strum_discriminants(strum( - message = "build - Build a NEAR contract and optionally embed ABI" - ))] - /// Build a NEAR contract and optionally embed ABI - Build(self::build_command::BuildCommand), - #[strum_discriminants(strum(message = "abi - Generates ABI for the contract"))] - /// Generates ABI for the contract - Abi(self::abi_command::AbiCommand), + pub cmd: self::commands::NearCommand, } diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 9b1c39a8..cd98e3f2 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -45,18 +45,18 @@ macro_rules! invoke_cargo_near { let cargo_near::CliOpts::Near(cli_args) = cargo_near::Opts::try_parse_from($cli_opts)?; match cli_args.cmd { - Some(cargo_near::CliNearCommand::Abi(cmd)) => { - let args = cargo_near::abi_command::AbiCommand { + Some(cargo_near::commands::CliNearCommand::Abi(cmd)) => { + let args = cargo_near::commands::abi_command::AbiCommand { doc: cmd.doc, compact_abi: cmd.compact_abi, out_dir: cmd.out_dir, manifest_path: Some(cargo_near::types::utf8_path_buf::Utf8PathBufInner(cargo_path)), color: cmd.color, }; - cargo_near::abi_command::abi::run(args)?; + cargo_near::commands::abi_command::abi::run(args)?; }, - Some(cargo_near::CliNearCommand::Build(cmd)) => { - let args = cargo_near::build_command::BuildCommand { + Some(cargo_near::commands::CliNearCommand::Build(cmd)) => { + let args = cargo_near::commands::build_command::BuildCommand { release: cmd.release, embed_abi: cmd.embed_abi, doc: cmd.doc, @@ -65,8 +65,7 @@ macro_rules! invoke_cargo_near { manifest_path: Some(cargo_near::types::utf8_path_buf::Utf8PathBufInner(cargo_path)), color: cmd.color, }; - println!("### {args:?}"); - cargo_near::build_command::build::run(args)?; + cargo_near::commands::build_command::build::run(args)?; }, None => () }