Skip to content

Commit

Permalink
fix: placeholder for contract and enum_variants error
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexD10S committed Jun 10, 2024
1 parent 072e137 commit 8f58b73
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 33 deletions.
21 changes: 3 additions & 18 deletions crates/pop-cli/src/commands/new/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@ pub struct NewContractCommand {
pub(crate) template: Option<Template>,
}

#[macro_export]
macro_rules! enum_variants {
($e: ty) => {{
PossibleValuesParser::new(
<$e>::VARIANTS
.iter()
.map(|p| PossibleValue::new(p.as_ref()))
.collect::<Vec<_>>(),
)
.try_map(|s| {
<$e>::from_str(&s).map_err(|e| format!("could not convert from {s} to provider"))
})
}};
}

impl NewContractCommand {
pub(crate) async fn execute(&self) -> Result<()> {
clear_screen()?;
Expand Down Expand Up @@ -79,8 +64,8 @@ async fn guide_user_to_generate_contract() -> Result<NewContractCommand> {
.interact()?;

let path: String = input("Where should your project be created?")
.placeholder("../")
.default_input("../")
.placeholder("./")
.default_input("./")
.interact()?;

let mut prompt = cliclack::select("Select a template provider: ".to_string());
Expand Down Expand Up @@ -113,8 +98,8 @@ fn generate_contract_from_template(
template.name(),
))?;
let contract_path = check_destination_path(path, name)?;

fs::create_dir_all(contract_path.as_path())?;

let spinner = cliclack::spinner();
spinner.start("Generating contract...");

Expand Down
15 changes: 15 additions & 0 deletions crates/pop-cli/src/commands/new/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ pub mod pallet;
#[cfg(feature = "parachain")]
pub mod parachain;

#[macro_export]
macro_rules! enum_variants {
($e: ty) => {{
PossibleValuesParser::new(
<$e>::VARIANTS
.iter()
.map(|p| PossibleValue::new(p.as_ref()))
.collect::<Vec<_>>(),
)
.try_map(|s| {
<$e>::from_str(&s).map_err(|e| format!("could not convert from {s} to provider"))
})
}};
}

#[derive(Args)]
#[command(args_conflicts_with_subcommands = true)]
pub struct NewArgs {
Expand Down
15 changes: 0 additions & 15 deletions crates/pop-cli/src/commands/new/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,6 @@ pub struct NewParachainCommand {
pub(crate) initial_endowment: Option<String>,
}

#[macro_export]
macro_rules! enum_variants {
($e: ty) => {{
PossibleValuesParser::new(
<$e>::VARIANTS
.iter()
.map(|p| PossibleValue::new(p.as_ref()))
.collect::<Vec<_>>(),
)
.try_map(|s| {
<$e>::from_str(&s).map_err(|e| format!("could not convert from {s} to provider"))
})
}};
}

impl NewParachainCommand {
pub(crate) async fn execute(&self) -> Result<Template> {
clear_screen()?;
Expand Down

0 comments on commit 8f58b73

Please sign in to comment.