use super::bundletool;
use crate::error::*;
use std::path::{Path, PathBuf};
#[derive(Debug, Default)]
pub struct InstallApks {
apks: PathBuf,
local_testing: bool,
device_id: Option<String>,
}
impl InstallApks {
pub fn new(apks: &Path) -> Self {
Self {
apks: apks.to_owned(),
..Default::default()
}
}
pub fn local_testing(&mut self, local_testing: bool) -> &mut Self {
self.local_testing = local_testing;
self
}
pub fn device_id(&mut self, device_id: String) -> &mut Self {
self.device_id = Some(device_id);
self
}
pub fn run(&self) -> Result<()> {
let mut install_apks = bundletool()?;
install_apks.arg("install-apks");
install_apks.arg("--apks");
install_apks.arg(&self.apks);
if self.local_testing {
install_apks.arg("--local-testing");
}
if let Some(device_id) = &self.device_id {
install_apks.arg("--device-id").arg(device_id);
}
install_apks.output_err(true)?;
Ok(())
}
}