diff --git a/zk_toolbox/Cargo.lock b/zk_toolbox/Cargo.lock index 7679313e9d68..8cfe5103730c 100644 --- a/zk_toolbox/Cargo.lock +++ b/zk_toolbox/Cargo.lock @@ -752,6 +752,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "deunicode" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" + [[package]] name = "diff" version = "0.1.13" @@ -3189,6 +3195,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slug" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd94acec9c8da640005f8e135a39fc0372e74535e6b368b7a04b875f784c8c4" +dependencies = [ + "deunicode", + "wasm-bindgen", +] + [[package]] name = "smallvec" version = "1.13.1" @@ -4558,6 +4574,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", + "slug", "strum 0.26.2", "strum_macros 0.26.2", "thiserror", diff --git a/zk_toolbox/Cargo.toml b/zk_toolbox/Cargo.toml index 15e1ddc4cdcb..70ca93236aeb 100644 --- a/zk_toolbox/Cargo.toml +++ b/zk_toolbox/Cargo.toml @@ -29,6 +29,7 @@ types = { path = "crates/types" } # External dependencies anyhow = "1.0.82" clap = { version = "4.4", features = ["derive", "wrap_help"] } +slug = "0.1.5" cliclack = "0.2.5" console = "0.15.8" ethers = "2.0" diff --git a/zk_toolbox/crates/common/src/lib.rs b/zk_toolbox/crates/common/src/lib.rs index 349cd751c5f6..a6ada02a8fd6 100644 --- a/zk_toolbox/crates/common/src/lib.rs +++ b/zk_toolbox/crates/common/src/lib.rs @@ -1,3 +1,7 @@ +pub use prerequisites::check_prerequisites; +pub use prompt::{init_prompt_theme, Prompt, PromptConfirm, PromptSelect}; +pub use term::{logger, spinner}; + pub mod cmd; pub mod config; pub mod db; @@ -7,11 +11,5 @@ pub mod files; pub mod forge; mod prerequisites; mod prompt; -mod slugify; mod term; pub mod wallets; - -pub use prerequisites::check_prerequisites; -pub use prompt::{init_prompt_theme, Prompt, PromptConfirm, PromptSelect}; -pub use slugify::slugify; -pub use term::{logger, spinner}; diff --git a/zk_toolbox/crates/common/src/slugify.rs b/zk_toolbox/crates/common/src/slugify.rs deleted file mode 100644 index 5e9940efb8e2..000000000000 --- a/zk_toolbox/crates/common/src/slugify.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn slugify(data: &str) -> String { - data.trim().replace(' ', "-") -} diff --git a/zk_toolbox/crates/zk_inception/Cargo.toml b/zk_toolbox/crates/zk_inception/Cargo.toml index ff22e982e3cc..7d8bf6055625 100644 --- a/zk_toolbox/crates/zk_inception/Cargo.toml +++ b/zk_toolbox/crates/zk_inception/Cargo.toml @@ -31,3 +31,4 @@ strum.workspace = true toml.workspace = true url.workspace = true thiserror.workspace = true +slug.workspace = true \ No newline at end of file diff --git a/zk_toolbox/crates/zk_inception/src/commands/chain/args/create.rs b/zk_toolbox/crates/zk_inception/src/commands/chain/args/create.rs index 986482df80b2..f527d5b8d577 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/chain/args/create.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/chain/args/create.rs @@ -1,7 +1,7 @@ use std::{path::PathBuf, str::FromStr}; use clap::Parser; -use common::{slugify, Prompt, PromptConfirm, PromptSelect}; +use common::{Prompt, PromptConfirm, PromptSelect}; use serde::{Deserialize, Serialize}; use strum::IntoEnumIterator; use strum_macros::{Display, EnumIter}; @@ -26,7 +26,7 @@ use crate::{ pub struct ChainCreateArgs { #[arg(long)] pub chain_name: Option, - #[arg(value_parser = clap::value_parser!(u32).range(1..))] + #[arg(value_parser = clap::value_parser ! (u32).range(1..))] pub chain_id: Option, #[clap(long, help = MSG_PROVER_MODE_HELP, value_enum)] pub prover_mode: Option, @@ -55,7 +55,7 @@ impl ChainCreateArgs { let mut chain_name = self .chain_name .unwrap_or_else(|| Prompt::new(MSG_CHAIN_NAME_PROMPT).ask()); - chain_name = slugify(&chain_name); + chain_name = slug::slugify(&chain_name); let chain_id = self.chain_id.unwrap_or_else(|| { Prompt::new(MSG_CHAIN_ID_PROMPT) diff --git a/zk_toolbox/crates/zk_inception/src/commands/chain/args/genesis.rs b/zk_toolbox/crates/zk_inception/src/commands/chain/args/genesis.rs index d835b1eb36a6..9bab215281f8 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/chain/args/genesis.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/chain/args/genesis.rs @@ -1,5 +1,5 @@ use clap::Parser; -use common::{db::DatabaseConfig, slugify, Prompt}; +use common::{db::DatabaseConfig, Prompt}; use config::ChainConfig; use serde::{Deserialize, Serialize}; use url::Url; @@ -48,7 +48,7 @@ impl GenesisArgs { .default(DATABASE_SERVER_URL.as_str()) .ask() }); - let server_db_name = slugify(&self.server_db_name.unwrap_or_else(|| { + let server_db_name = slug::slugify(&self.server_db_name.unwrap_or_else(|| { Prompt::new(&msg_server_db_name_prompt(&chain_name)) .default(&server_name) .ask() @@ -58,7 +58,7 @@ impl GenesisArgs { .default(DATABASE_PROVER_URL.as_str()) .ask() }); - let prover_db_name = slugify(&self.prover_db_name.unwrap_or_else(|| { + let prover_db_name = slug::slugify(&self.prover_db_name.unwrap_or_else(|| { Prompt::new(&msg_prover_db_name_prompt(&chain_name)) .default(&prover_name) .ask() diff --git a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs index 77ee3d42966a..d649f05b52ba 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use clap::Parser; -use common::{slugify, Prompt, PromptConfirm, PromptSelect}; +use common::{Prompt, PromptConfirm, PromptSelect}; use serde::{Deserialize, Serialize}; use strum::IntoEnumIterator; use strum_macros::EnumIter; @@ -37,7 +37,7 @@ impl EcosystemCreateArgs { let mut ecosystem_name = self .ecosystem_name .unwrap_or_else(|| Prompt::new(MSG_ECOSYSTEM_NAME_PROMPT).ask()); - ecosystem_name = slugify(&ecosystem_name); + ecosystem_name = slug::slugify(&ecosystem_name); let link_to_code = self.link_to_code.unwrap_or_else(|| { let link_to_code_selection =