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(()); +}