fix: dont prompt when no packages are configured

This commit is contained in:
daimond113 2024-12-09 11:41:54 +01:00
parent e51bc9f9bb
commit 4843424dba
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C

View file

@ -142,7 +142,10 @@ impl InitCommand {
.await .await
.context("failed to get source config")?; .context("failed to get source config")?;
let scripts_package = inquire::Select::new( let scripts_package = if config.scripts_packages.is_empty() {
PackageNameOrCustom::Custom
} else {
inquire::Select::new(
"which scripts package do you want to use?", "which scripts package do you want to use?",
config config
.scripts_packages .scripts_packages
@ -152,12 +155,13 @@ impl InitCommand {
.collect(), .collect(),
) )
.prompt() .prompt()
.unwrap(); .unwrap()
};
let scripts_package = match scripts_package { let scripts_package = match scripts_package {
PackageNameOrCustom::PackageName(p) => Some(p), PackageNameOrCustom::PackageName(p) => Some(p),
PackageNameOrCustom::Custom => { PackageNameOrCustom::Custom => {
let name = inquire::Text::new("which package to use?") let name = inquire::Text::new("which scripts package to use?")
.with_validator(|name: &str| { .with_validator(|name: &str| {
if name.is_empty() { if name.is_empty() {
return Ok(Validation::Valid); return Ok(Validation::Valid);