From 262ea4c50b4bee87db7213c495da3d640c5a0c73 Mon Sep 17 00:00:00 2001
From: Nicolas80 <nicolas.pmail@protonmail.com>
Date: Wed, 1 Jan 2025 17:23:02 +0100
Subject: [PATCH] * Fixed small bug after switching from `dialoguer` to
 `inquire`: using `prompt_skippable()` only returns `None` if the user presses
 `Esc` (returned "" when user just pressed enter) * Now using `prompt()` and
 checking empty string again.

---
 src/inputs.rs | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/inputs.rs b/src/inputs.rs
index acbe331..e430312 100644
--- a/src/inputs.rs
+++ b/src/inputs.rs
@@ -24,9 +24,9 @@ pub fn prompt_password_query_confirm(query: impl ToString) -> Result<String, Gcl
 
 /// Prompt for a (direct) vault name (cannot contain derivation path)
 ///
-/// Also preventing to use '<' and '>' as those are used in the display of
+/// Also preventing to use '<' and '>' as those are used in the display
 pub fn prompt_vault_name() -> Result<Option<String>, GcliError> {
-	inquire::Text::new("Name:")
+	let name = inquire::Text::new("Name:")
 		.with_validator(|input: &str| {
 			if input.contains('<') || input.contains('>') || input.contains('/') {
 				Ok(Validation::Invalid(
@@ -36,8 +36,14 @@ pub fn prompt_vault_name() -> Result<Option<String>, GcliError> {
 				Ok(Validation::Valid)
 			}
 		})
-		.prompt_skippable()
-		.map_err(|e| GcliError::Input(e.to_string()))
+		.prompt()
+		.map_err(|e| GcliError::Input(e.to_string()))?;
+
+	Ok(if name.trim().is_empty() {
+		None
+	} else {
+		Some(name.trim().to_string())
+	})
 }
 
 /// Prompt for a derivation path
-- 
GitLab