From 81a8218794b046e15f7323d124e260fc50ed916a Mon Sep 17 00:00:00 2001 From: pepa65 Date: Wed, 30 Oct 2024 20:00:56 +0700 Subject: [PATCH] Yes/NO defaults to "no" when just enter is pressed (#1948) * yes/NO in interface * Implement No as default (when only Enter is pressed) * Update README.md Mark the default as [yes] Signed-off-by: pepa65 * Update ui.rs Mark the default as [yes] Signed-off-by: pepa65 * Update ui.rs Do not break on yes/y/YES/Y/"", break on no/n/NO/N, and keep asking otherwise Signed-off-by: pepa65 * Update ui.rs After testing empty didn't work correctly Signed-off-by: pepa65 --------- Signed-off-by: pepa65 --- README.md | 2 +- crates/bin/src/ui.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2a40466b..d8a49b50 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ $ cargo binstall radio-sx128x@0.14.1-alpha.5 WARN The package radio-sx128x v0.14.1-alpha.5 (x86_64-unknown-linux-gnu) has been downloaded from github.com INFO This will install the following binaries: INFO - sx128x-util (sx128x-util-x86_64-unknown-linux-gnu -> /home/.cargo/bin/sx128x-util) -Do you wish to continue? yes/[no] +Do you wish to continue? [yes]/no ? yes INFO Installing binaries... INFO Done in 2.838798298s diff --git a/crates/bin/src/ui.rs b/crates/bin/src/ui.rs index ff02d2ec..bcbb67e1 100644 --- a/crates/bin/src/ui.rs +++ b/crates/bin/src/ui.rs @@ -10,7 +10,7 @@ fn ask_for_confirm(stdin: &mut StdinLock, input: &mut String) -> io::Result<()> { let mut stdout = io::stdout().lock(); - write!(&mut stdout, "Do you wish to continue? yes/[no]\n? ")?; + write!(&mut stdout, "Do you wish to continue? [yes]/no\n? ")?; stdout.flush()?; } @@ -34,8 +34,8 @@ pub async fn confirm() -> Result<(), BinstallError> { } match input.as_str().trim() { - "yes" | "y" | "YES" | "Y" => break true, - "no" | "n" | "NO" | "N" | "" => break false, + "yes" | "y" | "YES" | "Y" | "" => break true, + "no" | "n" | "NO" | "N" => break false, _ => { input.clear(); continue;