move generate code subcommand impl

This commit is contained in:
Carson McManus 2022-06-19 11:54:42 -04:00
parent 31c08ac206
commit aaded51d38

View file

@ -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<Arc<Mutex<SteamGuardAccount>>>) -> 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(());
}