diff --git a/src/tui.rs b/src/tui.rs index 37b2231..da59d90 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -125,6 +125,10 @@ where pub(crate) fn prompt_confirmation_menu( confirmations: Vec, ) -> anyhow::Result<(Vec, Vec)> { + if confirmations.len() == 0 { + bail!("no confirmations") + } + let mut to_accept_idx: HashSet = HashSet::new(); let mut to_deny_idx: HashSet = HashSet::new(); diff --git a/steamguard/src/lib.rs b/steamguard/src/lib.rs index 0f02adb..59fb957 100644 --- a/steamguard/src/lib.rs +++ b/steamguard/src/lib.rs @@ -13,7 +13,7 @@ use reqwest::{ use scraper::{Html, Selector}; pub use secrecy::{ExposeSecret, SecretString}; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, convert::TryInto}; +use std::{collections::HashMap, convert::TryInto, io::Read}; use steamapi::SteamApiClient; pub use userlogin::{LoginError, UserLogin}; #[macro_use] @@ -94,6 +94,13 @@ impl SteamGuardAccount { }; } + pub fn from_reader(r: T) -> anyhow::Result + where + T: Read, + { + Ok(serde_json::from_reader(r)?) + } + pub fn set_session(&mut self, session: steamapi::Session) { self.session = Some(session.into()); }