diff --git a/crates/pop-cli/src/commands/new/parachain.rs b/crates/pop-cli/src/commands/new/parachain.rs index c1d7b640..0f081ee1 100644 --- a/crates/pop-cli/src/commands/new/parachain.rs +++ b/crates/pop-cli/src/commands/new/parachain.rs @@ -1,17 +1,16 @@ // SPDX-License-Identifier: GPL-3.0 -use crate::style::{style, Theme}; +use crate::cli::{traits::Cli as _, Cli}; +use crate::style::style; use anyhow::Result; use clap::{ builder::{PossibleValue, PossibleValuesParser, TypedValueParser}, Args, }; -use std::{fs, path::Path, str::FromStr}; - use cliclack::{ - clear_screen, confirm, input, intro, + clear_screen, confirm, input, log::{self, success, warning}, - outro, outro_cancel, set_theme, + outro, outro_cancel, }; use pop_common::{ enum_variants, @@ -21,6 +20,7 @@ use pop_common::{ use pop_parachains::{ instantiate_template_dir, is_initial_endowment_valid, Config, Parachain, Provider, }; +use std::{fs, path::Path, str::FromStr, thread::sleep, time::Duration}; use strum::VariantArray; const DEFAULT_INITIAL_ENDOWMENT: &str = "1u64 << 60"; @@ -64,9 +64,6 @@ pub struct NewParachainCommand { impl NewParachainCommand { /// Executes the command. pub(crate) async fn execute(self) -> Result { - clear_screen()?; - set_theme(Theme); - let parachain_config = if self.name.is_none() { // If user doesn't select the name guide them to generate a parachain. guide_user_to_generate_parachain().await? @@ -94,13 +91,14 @@ impl NewParachainCommand { let tag_version = parachain_config.release_tag.clone(); + clear_screen()?; generate_parachain_from_template(name, provider, &template, tag_version, config)?; Ok(template) } } async fn guide_user_to_generate_parachain() -> Result { - intro(format!("{}: Generate a parachain", style(" Pop CLI ").black().on_magenta()))?; + Cli.intro("Generate a parachain")?; let mut prompt = cliclack::select("Select a template provider: ".to_string()); for (i, provider) in Provider::types().iter().enumerate() { @@ -137,8 +135,6 @@ async fn guide_user_to_generate_parachain() -> Result { customizable_options = prompt_customizable_options()?; } - clear_screen()?; - Ok(NewParachainCommand { name: Some(name), provider: Some(provider.clone()), @@ -157,10 +153,8 @@ fn generate_parachain_from_template( tag_version: Option, config: Config, ) -> Result<()> { - intro(format!( - "{}: Generating \"{}\" using {} from {}!", - style(" Pop CLI ").black().on_magenta(), - name_template, + Cli.intro(format!( + "Generating \"{name_template}\" using {} from {}!", template.name(), provider.name() ))?; @@ -246,6 +240,7 @@ fn get_customization_value( && (symbol.is_some() || decimals.is_some() || initial_endowment.is_some()) { log::warning("Customization options are not available for this template")?; + sleep(Duration::from_secs(3)) } return Ok(Config { symbol: symbol.clone().expect("default values"), @@ -360,7 +355,7 @@ fn prompt_customizable_options() -> Result { .interact()?; if !is_initial_endowment_valid(&initial_endowment) { outro_cancel("⚠️ The specified initial endowment is not valid")?; - //Prompt the user if want to use the one by default + // Prompt the user if they want to use the one by default if !confirm(format!("📦 Would you like to use the default {}?", DEFAULT_INITIAL_ENDOWMENT)) .initial_value(true) .interact()?