mirror of
https://github.com/nab138/isideload.git
synced 2026-03-02 06:26:16 +01:00
cache team
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1831,7 +1831,7 @@ checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
||||
|
||||
[[package]]
|
||||
name = "isideload"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"aes 0.9.0-rc.4",
|
||||
"aes-gcm",
|
||||
|
||||
@@ -117,7 +117,7 @@ async fn main() {
|
||||
};
|
||||
|
||||
let mut sideloader = SideloaderBuilder::new(dev_session, apple_id.to_string())
|
||||
.team_selection(TeamSelection::Prompt(team_selection_prompt))
|
||||
.team_selection(TeamSelection::PromptOnce(team_selection_prompt))
|
||||
.max_certs_behavior(MaxCertsBehavior::Prompt(cert_selection_prompt))
|
||||
.machine_name("isideload-minimal".to_string())
|
||||
.build();
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "isideload"
|
||||
description = "Sideload iOS/iPadOS applications"
|
||||
license = "MIT"
|
||||
authors = ["Nicholas Sharp <nab@nabdev.me>"]
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
edition = "2024"
|
||||
repository = "https://github.com/nab138/isideload"
|
||||
documentation = "https://docs.rs/isideload"
|
||||
|
||||
@@ -13,18 +13,22 @@ use crate::{
|
||||
///
|
||||
/// If there is only one team, it will be selected automatically regardless of this setting.
|
||||
/// If there are multiple teams, the behavior will depend on this setting.
|
||||
#[derive(Clone)]
|
||||
pub enum TeamSelection {
|
||||
/// Select the first team automatically
|
||||
First,
|
||||
/// Prompt the user to select a team
|
||||
Prompt(fn(&Vec<DeveloperTeam>) -> Option<String>),
|
||||
/// Prompt the user to select a team the first time this sideloader is used, and remember the selection for future runs
|
||||
PromptOnce(fn(&Vec<DeveloperTeam>) -> Option<String>),
|
||||
/// Prompt the user to select a team every time this sideloader is used
|
||||
PromptAlways(fn(&Vec<DeveloperTeam>) -> Option<String>),
|
||||
}
|
||||
|
||||
impl Display for TeamSelection {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
TeamSelection::First => write!(f, "first team"),
|
||||
TeamSelection::Prompt(_) => write!(f, "prompting for team"),
|
||||
TeamSelection::PromptOnce(_) => write!(f, "prompting for team (once)"),
|
||||
TeamSelection::PromptAlways(_) => write!(f, "prompting for team (always)"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ pub struct Sideloader {
|
||||
max_certs_behavior: MaxCertsBehavior,
|
||||
//extensions_behavior: ExtensionsBehavior,
|
||||
delete_app_after_install: bool,
|
||||
team: Option<DeveloperTeam>,
|
||||
}
|
||||
|
||||
impl Sideloader {
|
||||
@@ -56,6 +57,7 @@ impl Sideloader {
|
||||
max_certs_behavior,
|
||||
//extensions_behavior,
|
||||
delete_app_after_install,
|
||||
team: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,8 +221,11 @@ impl Sideloader {
|
||||
|
||||
/// Get the developer team according to the configured team selection behavior
|
||||
pub async fn get_team(&mut self) -> Result<DeveloperTeam, Report> {
|
||||
if let Some(team) = &self.team {
|
||||
return Ok(team.clone());
|
||||
}
|
||||
let teams = self.dev_session.list_teams().await?;
|
||||
Ok(match teams.len() {
|
||||
let team = match teams.len() {
|
||||
0 => {
|
||||
bail!("No developer teams available")
|
||||
}
|
||||
@@ -232,7 +237,8 @@ impl Sideloader {
|
||||
);
|
||||
match &self.team_selection {
|
||||
TeamSelection::First => teams.into_iter().next().unwrap(),
|
||||
TeamSelection::Prompt(prompt_fn) => {
|
||||
TeamSelection::PromptOnce(prompt_fn)
|
||||
| TeamSelection::PromptAlways(prompt_fn) => {
|
||||
let selection =
|
||||
prompt_fn(&teams).ok_or_else(|| report!("No team selected"))?;
|
||||
teams
|
||||
@@ -242,6 +248,10 @@ impl Sideloader {
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
if !matches!(&self.team_selection, TeamSelection::PromptAlways(_)) {
|
||||
self.team = Some(team.clone());
|
||||
}
|
||||
Ok(team)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user