Skip to content

Commit

Permalink
Yes/NO defaults to "no" when just enter is pressed (#1948)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update ui.rs

Mark the default as [yes]

Signed-off-by: pepa65 <[email protected]>

* 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 <[email protected]>

* Update ui.rs

After testing empty didn't work correctly

Signed-off-by: pepa65 <[email protected]>

---------

Signed-off-by: pepa65 <[email protected]>
  • Loading branch information
pepa65 authored Oct 30, 2024
1 parent e704abe commit 81a8218
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ cargo binstall [email protected]
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
Expand Down
6 changes: 3 additions & 3 deletions crates/bin/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
}

Expand All @@ -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;
Expand Down

0 comments on commit 81a8218

Please sign in to comment.