From 2ae368d97e07271b713beacb3a7f274c7e07ad66 Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Tue, 13 Aug 2024 20:29:26 +0200 Subject: [PATCH] fix: correctly add authors array --- src/cli/commands/init.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/cli/commands/init.rs b/src/cli/commands/init.rs index dfe1198..ec60a58 100644 --- a/src/cli/commands/init.rs +++ b/src/cli/commands/init.rs @@ -1,12 +1,15 @@ -use crate::cli::config::read_config; +use std::{path::Path, str::FromStr}; + use anyhow::Context; use clap::Args; use colored::Colorize; use inquire::validator::Validation; + use pesde::{ errors::ManifestReadError, names::PackageName, scripts::ScriptName, Project, DEFAULT_INDEX_NAME, }; -use std::{path::Path, str::FromStr}; + +use crate::cli::config::read_config; #[derive(Debug, Args)] pub struct InitCommand {} @@ -67,11 +70,15 @@ impl InitCommand { .prompt() .unwrap(); - authors + let authors = authors .split(',') - .map(|s| s.trim()) + .map(str::trim) .filter(|s| !s.is_empty()) - .for_each(|author| manifest["authors"].as_array_mut().unwrap().push(author)); + .collect::(); + + if !authors.is_empty() { + manifest["authors"] = toml_edit::value(authors); + } let repo = inquire::Text::new( "What is the repository URL of this project? (leave empty for none)",