Skip to content

Commit

Permalink
fix: parse user import correctly in delete subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
replydev committed Jul 29, 2024
1 parent 4d74db8 commit 8ed354f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/arguments/delete.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io::{self};
use std::io::{self, Write};

use clap::Args;
use color_eyre::eyre::eyre;
Expand Down Expand Up @@ -33,14 +33,17 @@ impl SubcommandExecutor for DeleteArgs {
let mut output = String::with_capacity(1);

let element = otp_database.elements_ref().get(index_to_delete).unwrap();
println!(
print!(
"Are you sure you want to delete the {}th code ({}, {}) [Y,N]: ",
index_to_delete, element.issuer, element.label
index_to_delete + 1,
element.issuer,
element.label
);
io::stdout().flush()?;

io::stdin().read_line(&mut output)?;

if output.eq_ignore_ascii_case("y") {
if output.trim().eq_ignore_ascii_case("y") {
otp_database.delete_element(index_to_delete);
Ok(otp_database)
} else {
Expand Down

0 comments on commit 8ed354f

Please sign in to comment.