From aaded51d38d75f4d60361274a666e7917a357867 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sun, 19 Jun 2022 11:54:42 -0400 Subject: [PATCH] move generate code subcommand impl --- src/main.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index b262468..a6c64d5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -285,18 +285,7 @@ fn run() -> anyhow::Result<()> { }, _ => { debug!("No subcommand given, assuming user wants a 2fa code"); - - let server_time = steamapi::get_server_time(); - debug!("Time used to generate codes: {}", server_time); - for account in selected_accounts { - info!( - "Generating code for {}", - account.lock().unwrap().account_name - ); - trace!("{:?}", account); - let code = account.lock().unwrap().generate_code(server_time); - println!("{}", code); - } + return do_subcmd_code(selected_accounts); } } @@ -725,3 +714,18 @@ fn do_subcmd_decrypt(args: cli::ArgsDecrypt, manifest: &mut accountmanager::Mani manifest.save()?; return Ok(()); } + +fn do_subcmd_code(selected_accounts: Vec>>) -> anyhow::Result<()> { + let server_time = steamapi::get_server_time(); + debug!("Time used to generate codes: {}", server_time); + for account in selected_accounts { + info!( + "Generating code for {}", + account.lock().unwrap().account_name + ); + trace!("{:?}", account); + let code = account.lock().unwrap().generate_code(server_time); + println!("{}", code); + } + return Ok(()); +}