Skip to content

Commit ab97990

Browse files
committed
admin/dialoguer: Remove .unwrap() call from confirm() fn
1 parent cf322b4 commit ab97990

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

src/admin/delete_crate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
7070
}
7171
println!();
7272

73-
if !opts.yes && !dialoguer::confirm("Do you want to permanently delete these crates?") {
73+
if !opts.yes && !dialoguer::confirm("Do you want to permanently delete these crates?")? {
7474
return Ok(());
7575
}
7676

src/admin/delete_version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
4747
}
4848
println!();
4949

50-
if !opts.yes && !dialoguer::confirm("Do you want to permanently delete these versions?") {
50+
if !opts.yes && !dialoguer::confirm("Do you want to permanently delete these versions?")? {
5151
return Ok(());
5252
}
5353

src/admin/dialoguer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use ::dialoguer::{theme::Theme, Confirm};
22

3-
pub fn confirm(msg: &str) -> bool {
3+
pub fn confirm(msg: &str) -> dialoguer::Result<bool> {
44
Confirm::with_theme(&CustomTheme)
55
.with_prompt(msg)
66
.default(false)
77
.wait_for_newline(true)
88
.interact()
9-
.unwrap()
109
}
1110

1211
#[derive(Debug, Copy, Clone)]

src/admin/transfer_crates.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn transfer(opts: Opts, conn: &mut PgConnection) -> anyhow::Result<()> {
4747
println!("from: {:?}", from.gh_id);
4848
println!("to: {:?}", to.gh_id);
4949

50-
if !dialoguer::confirm("continue?") {
50+
if !dialoguer::confirm("continue?")? {
5151
return Ok(());
5252
}
5353
}
@@ -56,7 +56,7 @@ fn transfer(opts: Opts, conn: &mut PgConnection) -> anyhow::Result<()> {
5656
"Are you sure you want to transfer crates from {} to {}?",
5757
from.gh_login, to.gh_login
5858
);
59-
if !dialoguer::confirm(&prompt) {
59+
if !dialoguer::confirm(&prompt)? {
6060
return Ok(());
6161
}
6262

@@ -74,7 +74,7 @@ fn transfer(opts: Opts, conn: &mut PgConnection) -> anyhow::Result<()> {
7474
}
7575
}
7676

77-
if !dialoguer::confirm("commit?") {
77+
if !dialoguer::confirm("commit?")? {
7878
return Ok(());
7979
}
8080

src/admin/upload_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
2727

2828
let files = repo.get_files_modified_since(opts.incremental_commit.as_deref())?;
2929
println!("found {} files to upload", files.len());
30-
if !dialoguer::confirm("continue with upload?") {
30+
if !dialoguer::confirm("continue with upload?")? {
3131
return Ok(());
3232
}
3333

src/admin/yank_version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn yank(opts: Opts, conn: &mut PgConnection) -> anyhow::Result<()> {
5353
"Are you sure you want to yank {crate_name}#{version} ({})?",
5454
v.id
5555
);
56-
if !dialoguer::confirm(&prompt) {
56+
if !dialoguer::confirm(&prompt)? {
5757
return Ok(());
5858
}
5959
}

0 commit comments

Comments
 (0)