Validate package name in init

This commit is contained in:
SkyfallWasTaken 2024-07-29 14:22:27 +01:00
parent bdd34ed8bb
commit b5c4759c98
3 changed files with 24 additions and 18 deletions

View file

@ -19,7 +19,8 @@ exitcode = "1.1.2"
env_logger = "0.11.3"
dialoguer = "0.11.0"
camino = "1.1.7"
gix-config = "0.37.0"
gix-config = "0.38.0"
maplit = "1.0.2"
serde_json = "1.0.120"
syntect = "5.2.0"
validate_package_name = { path = "../validate_package_name" }

View file

@ -47,6 +47,11 @@ pub async fn init() -> Result<()> {
// Now, onto the questions!
let package_name: String = Input::with_theme(&ColorfulTheme::default())
.with_prompt("Package name")
.validate_with(
|input: &String| -> Result<(), validate_package_name::Error> {
validate_package_name::validate(input)
},
)
.default(current_dir_name.into())
.interact_text()?;
let version: String = Input::with_theme(&ColorfulTheme::default())