cargo_unc/commands/build_command/
mod.rs

1pub mod build;
2
3#[derive(Debug, Default, Clone, interactive_clap::InteractiveClap)]
4#[interactive_clap(input_context = utility_cli_rs::GlobalContext)]
5#[interactive_clap(output_context = BuildCommandlContext)]
6pub struct BuildCommand {
7    /// Build contract in debug mode, without optimizations and bigger is size
8    #[interactive_clap(long)]
9    pub no_release: bool,
10    /// Do not generate ABI for the contract
11    #[interactive_clap(long)]
12    pub no_abi: bool,
13    /// Do not embed the ABI in the contract binary
14    #[interactive_clap(long)]
15    pub no_embed_abi: bool,
16    /// Do not include rustdocs in the embedded ABI
17    #[interactive_clap(long)]
18    pub no_doc: bool,
19    /// Copy final artifacts to this directory
20    #[interactive_clap(long)]
21    #[interactive_clap(skip_interactive_input)]
22    pub out_dir: Option<crate::types::utf8_path_buf::Utf8PathBuf>,
23    /// Path to the `Cargo.toml` of the contract to build
24    #[interactive_clap(long)]
25    #[interactive_clap(skip_interactive_input)]
26    pub manifest_path: Option<crate::types::utf8_path_buf::Utf8PathBuf>,
27    /// Set compile-time feature flags.
28    #[interactive_clap(long)]
29    #[interactive_clap(skip_interactive_input)]
30    pub features: Option<String>,
31    /// Disables default feature flags.
32    #[interactive_clap(long)]
33    #[interactive_clap(skip_interactive_input)]
34    pub no_default_features: bool,
35    /// Coloring: auto, always, never
36    #[interactive_clap(long)]
37    #[interactive_clap(value_enum)]
38    #[interactive_clap(skip_interactive_input)]
39    pub color: Option<crate::common::ColorPreference>,
40}
41
42#[derive(Debug, Clone)]
43pub struct BuildCommandlContext;
44
45impl BuildCommandlContext {
46    pub fn from_previous_context(
47        _previous_context: utility_cli_rs::GlobalContext,
48        scope: &<BuildCommand as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope,
49    ) -> color_eyre::eyre::Result<Self> {
50        let args = BuildCommand {
51            no_release: scope.no_release,
52            no_abi: scope.no_abi,
53            no_embed_abi: scope.no_embed_abi,
54            no_doc: scope.no_doc,
55            out_dir: scope.out_dir.clone(),
56            manifest_path: scope.manifest_path.clone(),
57            features: scope.features.clone(),
58            no_default_features: scope.no_default_features,
59            color: scope.color.clone(),
60        };
61        self::build::run(args)?;
62        Ok(Self)
63    }
64}