add account selection from arguments
This commit is contained in:
parent
8ded30e09e
commit
23257ee615
2 changed files with 27 additions and 3 deletions
|
@ -13,7 +13,7 @@ mod steamapi;
|
||||||
extern crate hmacsha1;
|
extern crate hmacsha1;
|
||||||
extern crate base64;
|
extern crate base64;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct SteamGuardAccount {
|
pub struct SteamGuardAccount {
|
||||||
pub account_name: String,
|
pub account_name: String,
|
||||||
pub serial_number: String,
|
pub serial_number: String,
|
||||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -1,4 +1,5 @@
|
||||||
extern crate rpassword;
|
extern crate rpassword;
|
||||||
|
use borrow::BorrowMut;
|
||||||
use io::Write;
|
use io::Write;
|
||||||
use steamguard_cli::*;
|
use steamguard_cli::*;
|
||||||
use ::std::*;
|
use ::std::*;
|
||||||
|
@ -26,6 +27,7 @@ fn main() {
|
||||||
Arg::with_name("all")
|
Arg::with_name("all")
|
||||||
.long("all")
|
.long("all")
|
||||||
.short("a")
|
.short("a")
|
||||||
|
.takes_value(false)
|
||||||
.help("Select all accounts in the manifest.")
|
.help("Select all accounts in the manifest.")
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -55,6 +57,7 @@ fn main() {
|
||||||
Arg::with_name("accept-all")
|
Arg::with_name("accept-all")
|
||||||
.short("a")
|
.short("a")
|
||||||
.long("accept-all")
|
.long("accept-all")
|
||||||
|
.takes_value(false)
|
||||||
.help("Accept all open trade confirmations. Does not open interactive interface.")
|
.help("Accept all open trade confirmations. Does not open interactive interface.")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -79,9 +82,30 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest.load_accounts();
|
manifest.load_accounts();
|
||||||
for account in manifest.accounts {
|
let mut selected_accounts: Vec<SteamGuardAccount> = vec![];
|
||||||
|
if matches.is_present("all") {
|
||||||
|
// manifest.accounts.iter().map(|a| selected_accounts.push(a.b));
|
||||||
|
for account in manifest.accounts {
|
||||||
|
selected_accounts.push(account.clone());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for account in manifest.accounts {
|
||||||
|
if !matches.is_present("username") {
|
||||||
|
selected_accounts.push(account.clone());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if matches.value_of("username").unwrap() == account.account_name {
|
||||||
|
selected_accounts.push(account.clone());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("selected accounts: {:?}", selected_accounts.iter().map(|a| a.account_name.clone()).collect::<Vec<String>>());
|
||||||
|
|
||||||
|
let server_time = steamapi::get_server_time();
|
||||||
|
for account in selected_accounts {
|
||||||
trace!("{:?}", account);
|
trace!("{:?}", account);
|
||||||
let server_time = steamapi::get_server_time();
|
|
||||||
let code = account.generate_code(server_time);
|
let code = account.generate_code(server_time);
|
||||||
println!("{}", code);
|
println!("{}", code);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue