Skip to content
Snippets Groups Projects
Commit 262ea4c5 authored by Nicolas80's avatar Nicolas80
Browse files

* Fixed small bug after switching from `dialoguer` to `inquire`: using...

* 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.
parent cf7a4292
No related branches found
No related tags found
1 merge request!41Adding db persistence for all SecretFormat of vault keys as well as supporting derivations
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment