diff --git a/src/lib.rs b/src/lib.rs index e526566..5639dcb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ mod steamapi; extern crate hmacsha1; extern crate base64; -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct SteamGuardAccount { pub account_name: String, pub serial_number: String, diff --git a/src/main.rs b/src/main.rs index ec703d5..b8cafee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ extern crate rpassword; +use borrow::BorrowMut; use io::Write; use steamguard_cli::*; use ::std::*; @@ -26,6 +27,7 @@ fn main() { Arg::with_name("all") .long("all") .short("a") + .takes_value(false) .help("Select all accounts in the manifest.") ) .arg( @@ -55,6 +57,7 @@ fn main() { Arg::with_name("accept-all") .short("a") .long("accept-all") + .takes_value(false) .help("Accept all open trade confirmations. Does not open interactive interface.") ) ) @@ -79,9 +82,30 @@ fn main() { } manifest.load_accounts(); - for account in manifest.accounts { + let mut selected_accounts: Vec = 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::>()); + + let server_time = steamapi::get_server_time(); + for account in selected_accounts { trace!("{:?}", account); - let server_time = steamapi::get_server_time(); let code = account.generate_code(server_time); println!("{}", code); }