Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/create-dev-account' into deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
FroVolod committed Oct 15, 2023
2 parents 7cf1e5f + 576cd25 commit b478d38
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 66 deletions.
41 changes: 10 additions & 31 deletions cargo-near/src/commands/abi_command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,21 @@ impl interactive_clap::FromCli for AbiCommand {
type FromCliError = color_eyre::eyre::Error;
fn from_cli(
optional_clap_variant: Option<<Self as interactive_clap::ToCli>::CliVariant>,
context: Self::FromCliContext,
_context: Self::FromCliContext,
) -> interactive_clap::ResultFromCli<
<Self as interactive_clap::ToCli>::CliVariant,
Self::FromCliError,
>
where
Self: Sized + interactive_clap::ToCli,
{
let mut clap_variant = optional_clap_variant.unwrap_or_default();
let doc = clap_variant.doc;
let compact_abi = clap_variant.compact_abi;
if clap_variant.out_dir.is_none() {
clap_variant.out_dir = match Self::input_out_dir(&context) {
Ok(optional_out_dir) => optional_out_dir,
Err(err) => return interactive_clap::ResultFromCli::Err(Some(clap_variant), err),
};
};
let out_dir = clap_variant.out_dir.clone();
if clap_variant.manifest_path.is_none() {
clap_variant.manifest_path = match Self::input_manifest_path(&context) {
Ok(optional_manifest_path) => optional_manifest_path,
Err(err) => return interactive_clap::ResultFromCli::Err(Some(clap_variant), err),
};
};
let manifest_path = clap_variant.manifest_path.clone();
if clap_variant.color.is_none() {
clap_variant.color = match Self::input_color(&context) {
Ok(optional_color) => optional_color,
Err(err) => return interactive_clap::ResultFromCli::Err(Some(clap_variant), err),
};
};
let color = clap_variant.color.clone();

let clap_variant = optional_clap_variant.unwrap_or_default();
let args = Self {
doc,
compact_abi,
out_dir,
manifest_path,
color,
doc: clap_variant.doc,
compact_abi: clap_variant.compact_abi,
out_dir: clap_variant.out_dir.clone(),
manifest_path: clap_variant.manifest_path.clone(),
color: clap_variant.color.clone(),
};
if let Err(err) = self::abi::run(args) {
interactive_clap::ResultFromCli::Err(Some(clap_variant), color_eyre::eyre::eyre!(err))
Expand All @@ -79,18 +55,21 @@ impl interactive_clap::FromCli for AbiCommand {
}

impl AbiCommand {
#[allow(dead_code)]
fn input_color(
_context: &near_cli_rs::GlobalContext,
) -> color_eyre::eyre::Result<Option<crate::common::ColorPreference>> {
Ok(None)
}

#[allow(dead_code)]
fn input_out_dir(
_context: &near_cli_rs::GlobalContext,
) -> color_eyre::eyre::Result<Option<crate::types::utf8_path_buf::Utf8PathBufInner>> {
Ok(None)
}

#[allow(dead_code)]
fn input_manifest_path(
_context: &near_cli_rs::GlobalContext,
) -> color_eyre::eyre::Result<Option<crate::types::utf8_path_buf::Utf8PathBufInner>> {
Expand Down
47 changes: 12 additions & 35 deletions cargo-near/src/commands/build_command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,49 +36,23 @@ impl interactive_clap::FromCli for BuildCommand {
type FromCliError = color_eyre::eyre::Error;
fn from_cli(
optional_clap_variant: Option<<Self as interactive_clap::ToCli>::CliVariant>,
context: Self::FromCliContext,
_context: Self::FromCliContext,
) -> interactive_clap::ResultFromCli<
<Self as interactive_clap::ToCli>::CliVariant,
Self::FromCliError,
>
where
Self: Sized + interactive_clap::ToCli,
{
let mut clap_variant = optional_clap_variant.unwrap_or_default();
let release = clap_variant.release;
let embed_abi = clap_variant.embed_abi;
let doc = clap_variant.doc;
let no_abi = clap_variant.no_abi;
if clap_variant.out_dir.is_none() {
clap_variant.out_dir = match Self::input_out_dir(&context) {
Ok(optional_out_dir) => optional_out_dir,
Err(err) => return interactive_clap::ResultFromCli::Err(Some(clap_variant), err),
};
};
let out_dir = clap_variant.out_dir.clone();
if clap_variant.manifest_path.is_none() {
clap_variant.manifest_path = match Self::input_manifest_path(&context) {
Ok(optional_manifest_path) => optional_manifest_path,
Err(err) => return interactive_clap::ResultFromCli::Err(Some(clap_variant), err),
};
};
let manifest_path = clap_variant.manifest_path.clone();
if clap_variant.color.is_none() {
clap_variant.color = match Self::input_color(&context) {
Ok(optional_color) => optional_color,
Err(err) => return interactive_clap::ResultFromCli::Err(Some(clap_variant), err),
};
};
let color = clap_variant.color.clone();

let clap_variant = optional_clap_variant.unwrap_or_default();
let args = Self {
release,
embed_abi,
doc,
no_abi,
out_dir,
manifest_path,
color,
release: clap_variant.release,
embed_abi: clap_variant.embed_abi,
doc: clap_variant.doc,
no_abi: clap_variant.no_abi,
out_dir: clap_variant.out_dir.clone(),
manifest_path: clap_variant.manifest_path.clone(),
color: clap_variant.color.clone(),
};
if let Err(err) = self::build::run(args).map(|_| ()) {
interactive_clap::ResultFromCli::Err(Some(clap_variant), color_eyre::eyre::eyre!(err))
Expand All @@ -89,18 +63,21 @@ impl interactive_clap::FromCli for BuildCommand {
}

impl BuildCommand {
#[allow(dead_code)]
fn input_color(
_context: &near_cli_rs::GlobalContext,
) -> color_eyre::eyre::Result<Option<crate::common::ColorPreference>> {
Ok(None)
}

#[allow(dead_code)]
fn input_out_dir(
_context: &near_cli_rs::GlobalContext,
) -> color_eyre::eyre::Result<Option<crate::types::utf8_path_buf::Utf8PathBufInner>> {
Ok(None)
}

#[allow(dead_code)]
fn input_manifest_path(
_context: &near_cli_rs::GlobalContext,
) -> color_eyre::eyre::Result<Option<crate::types::utf8_path_buf::Utf8PathBufInner>> {
Expand Down

0 comments on commit b478d38

Please sign in to comment.