Skip to content

Commit

Permalink
refactor: rename BuildContractCommand and BuildParachainCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexD10S committed Dec 19, 2024
1 parent 639bd23 commit f1963e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
13 changes: 6 additions & 7 deletions crates/pop-cli/src/commands/build/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ use crate::cli;
use pop_contracts::{build_smart_contract, Verbosity};
use std::path::PathBuf;

/// Command to build a smart contract with configurable path and release mode.
pub struct BuildContractCommand {
/// Path for the contract project [default: current directory]
/// Represents the configuration for building a smart contract.
pub struct BuildContract {
/// Path for the contract project.
pub(crate) path: Option<PathBuf>,
/// The default compilation includes debug functionality, increasing contract size and gas
/// usage. For production, always build in release mode to exclude debug features.
/// Build profile: `true` for release mode, `false` for debug mode.
pub(crate) release: bool,
}

impl BuildContractCommand {
impl BuildContract {
/// Executes the command.
pub(crate) fn execute(self) -> anyhow::Result<&'static str> {
self.build(&mut cli::Cli)
Expand Down Expand Up @@ -55,7 +54,7 @@ mod tests {
.expect_outro("Build completed successfully!");

assert_eq!(
BuildContractCommand { path: Some(path.join(name)), release }.build(&mut cli)?,
BuildContract { path: Some(path.join(name)), release }.build(&mut cli)?,
"contract"
);

Expand Down
14 changes: 7 additions & 7 deletions crates/pop-cli/src/commands/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
use crate::cli::{self, Cli};
use clap::{Args, Subcommand};
#[cfg(feature = "contract")]
use contract::BuildContractCommand;
use contract::BuildContract;
use duct::cmd;
use pop_common::Profile;
use std::path::PathBuf;
#[cfg(feature = "parachain")]
use {parachain::BuildParachainCommand, spec::BuildSpecCommand};
use {parachain::BuildParachain, spec::BuildSpecCommand};

#[cfg(feature = "contract")]
pub(crate) mod contract;
Expand Down Expand Up @@ -37,7 +37,7 @@ pub(crate) struct BuildArgs {
pub(crate) profile: Option<Profile>,
}

/// Build a parachain, smart contract, chain specification or Rust package.
/// Build a chain specification and its genesis artifacts.
#[derive(Subcommand)]
pub(crate) enum Command {
/// Build a chain specification and its genesis artifacts.
Expand All @@ -52,12 +52,12 @@ impl Command {
// If only contract feature enabled, build as contract
#[cfg(feature = "contract")]
if pop_contracts::is_supported(args.path.as_deref())? {
// All commands originating from root command are valid
// All arguments originating from root command are valid
let release = match args.profile {
Some(profile) => profile.into(),
None => args.release,
};
BuildContractCommand { path: args.path, release }.execute()?;
BuildContract { path: args.path, release }.execute()?;
return Ok("contract");
}

Expand All @@ -68,8 +68,8 @@ impl Command {
Some(profile) => profile,
None => args.release.into(),
};
// All commands originating from root command are valid
BuildParachainCommand {
// All arguments originating from root command are valid.
BuildParachain {
path: args.path.unwrap_or_else(|| PathBuf::from("./")),
package: args.package,
profile,
Expand Down
12 changes: 6 additions & 6 deletions crates/pop-cli/src/commands/build/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ use std::path::PathBuf;
#[cfg(not(test))]
use std::{thread::sleep, time::Duration};

/// Command to build a parachain with configurable path, package, and profile.
pub struct BuildParachainCommand {
/// Directory path for your project [default: current directory].
// Represents the configuration for building a parachain.
pub struct BuildParachain {
/// Directory path for your project.
pub(crate) path: PathBuf,
/// The package to be built.
pub(crate) package: Option<String>,
/// Build profile.
pub(crate) profile: Profile,
}

impl BuildParachainCommand {
/// Executes the command.
impl BuildParachain {
/// Executes the build process.
pub(crate) fn execute(self) -> anyhow::Result<&'static str> {
self.build(&mut cli::Cli)
}
Expand Down Expand Up @@ -110,7 +110,7 @@ mod tests {
}

assert_eq!(
BuildParachainCommand {
BuildParachain {
path: project_path.clone(),
package: package.clone(),
profile: profile.clone(),
Expand Down

0 comments on commit f1963e7

Please sign in to comment.