switch get_selected_accounts to new args

This commit is contained in:
Carson McManus 2022-06-19 12:57:54 -04:00
parent 174456226b
commit 2fc13d40e2

View file

@ -157,8 +157,8 @@ fn run() -> anyhow::Result<()> {
_ => {}, _ => {},
}; };
let mafiles_dir = if let Some(mafiles_path) = new_args.mafiles_path { let mafiles_dir = if let Some(mafiles_path) = &new_args.mafiles_path {
mafiles_path mafiles_path.clone()
} else { } else {
get_mafiles_dir() get_mafiles_dir()
}; };
@ -185,7 +185,7 @@ fn run() -> anyhow::Result<()> {
manifest = accountmanager::Manifest::load(path.as_path())?; manifest = accountmanager::Manifest::load(path.as_path())?;
} }
let mut passkey: Option<String> = new_args.passkey; let mut passkey: Option<String> = new_args.passkey.clone();
manifest.submit_passkey(passkey); manifest.submit_passkey(passkey);
loop { loop {
@ -234,7 +234,7 @@ fn run() -> anyhow::Result<()> {
let mut selected_accounts: Vec<Arc<Mutex<SteamGuardAccount>>>; let mut selected_accounts: Vec<Arc<Mutex<SteamGuardAccount>>>;
loop { loop {
match get_selected_accounts(&matches, &mut manifest) { match get_selected_accounts(&new_args, &mut manifest) {
Ok(accounts) => { Ok(accounts) => {
selected_accounts = accounts; selected_accounts = accounts;
break; break;
@ -283,19 +283,19 @@ fn run() -> anyhow::Result<()> {
} }
fn get_selected_accounts( fn get_selected_accounts(
matches: &ArgMatches, args: &cli::Args,
manifest: &mut accountmanager::Manifest, manifest: &mut accountmanager::Manifest,
) -> anyhow::Result<Vec<Arc<Mutex<SteamGuardAccount>>>, ManifestAccountLoadError> { ) -> anyhow::Result<Vec<Arc<Mutex<SteamGuardAccount>>>, ManifestAccountLoadError> {
let mut selected_accounts: Vec<Arc<Mutex<SteamGuardAccount>>> = vec![]; let mut selected_accounts: Vec<Arc<Mutex<SteamGuardAccount>>> = vec![];
if matches.is_present("all") { if args.all {
manifest.load_accounts()?; manifest.load_accounts()?;
for entry in &manifest.entries { for entry in &manifest.entries {
selected_accounts.push(manifest.get_account(&entry.account_name).unwrap().clone()); selected_accounts.push(manifest.get_account(&entry.account_name).unwrap().clone());
} }
} else { } else {
let entry = if matches.is_present("username") { let entry = if let Some(username) = &args.username {
manifest.get_entry(&matches.value_of("username").unwrap().into()) manifest.get_entry(&username)
} else { } else {
manifest manifest
.entries .entries