move generate code subcommand impl
This commit is contained in:
parent
31c08ac206
commit
aaded51d38
1 changed files with 16 additions and 12 deletions
28
src/main.rs
28
src/main.rs
|
@ -285,18 +285,7 @@ fn run() -> anyhow::Result<()> {
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
debug!("No subcommand given, assuming user wants a 2fa code");
|
debug!("No subcommand given, assuming user wants a 2fa code");
|
||||||
|
return do_subcmd_code(selected_accounts);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,3 +714,18 @@ fn do_subcmd_decrypt(args: cli::ArgsDecrypt, manifest: &mut accountmanager::Mani
|
||||||
manifest.save()?;
|
manifest.save()?;
|
||||||
return Ok(());
|
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(());
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue