mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
fix: dont prompt when no packages are configured
This commit is contained in:
parent
e51bc9f9bb
commit
4843424dba
1 changed files with 16 additions and 12 deletions
|
@ -142,22 +142,26 @@ 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() {
|
||||||
"which scripts package do you want to use?",
|
PackageNameOrCustom::Custom
|
||||||
config
|
} else {
|
||||||
.scripts_packages
|
inquire::Select::new(
|
||||||
.into_iter()
|
"which scripts package do you want to use?",
|
||||||
.map(PackageNameOrCustom::PackageName)
|
config
|
||||||
.chain(std::iter::once(PackageNameOrCustom::Custom))
|
.scripts_packages
|
||||||
.collect(),
|
.into_iter()
|
||||||
)
|
.map(PackageNameOrCustom::PackageName)
|
||||||
.prompt()
|
.chain(std::iter::once(PackageNameOrCustom::Custom))
|
||||||
.unwrap();
|
.collect(),
|
||||||
|
)
|
||||||
|
.prompt()
|
||||||
|
.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);
|
||||||
|
|
Loading…
Reference in a new issue