Skip to content

Commit

Permalink
fix: 🚀 remove otp-uri argument as now otp uris can be imported
Browse files Browse the repository at this point in the history
otp uri argument in add subcommand can be misleading
  • Loading branch information
replydev committed Feb 22, 2024
1 parent 0bb3f34 commit 5cb20ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
6 changes: 1 addition & 5 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ enum CotpSubcommands {

#[derive(Args)]
pub struct AddArgs {
/// Add OTP code via an OTP URI
#[arg(short = 'u', long = "otpuri", required_unless_present = "label")]
pub otp_uri: bool,

/// Specify the OTP code type
#[arg(short = 't', long = "type", default_value = "totp")]
pub otp_type: OTPType,
Expand All @@ -44,7 +40,7 @@ pub struct AddArgs {
pub issuer: String,

/// Code label
#[arg(short, long, required_unless_present = "otp_uri")]
#[arg(short, long, required = true)]
pub label: Option<String>,

/// OTP Algorithm
Expand Down
11 changes: 2 additions & 9 deletions src/argument_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::importers::authy_remote_debug::AuthyExportedList;
use crate::importers::converted::ConvertedJsonList;
use crate::importers::freeotp_plus::FreeOTPPlusJson;
use crate::importers::importer::import_from_path;
use crate::otp::from_otp_uri::FromOtpUri;
use crate::otp::otp_element::{OTPDatabase, OTPElement};
use crate::utils;
use color_eyre::eyre::{eyre, ErrReport};
Expand Down Expand Up @@ -49,14 +48,8 @@ pub fn import(matches: ImportArgs, mut database: OTPDatabase) -> color_eyre::Res
}

pub fn add(matches: AddArgs, mut database: OTPDatabase) -> color_eyre::Result<OTPDatabase> {
let otp_element = if matches.otp_uri {
let mut otp_uri = rpassword::prompt_password("Insert the otp uri: ").unwrap();
let result = OTPElement::from_otp_uri(otp_uri.as_str());
otp_uri.zeroize();
result?
} else {
get_from_args(matches)?
};
let otp_element = get_from_args(matches)?;

if !otp_element.valid_secret() {
return Err(ErrReport::msg("Invalid secret."));
}
Expand Down

0 comments on commit 5cb20ae

Please sign in to comment.