android_tools_rs/bundletool/
get_device_spec.rs1use crate::error::*;
2use std::path::{Path, PathBuf};
3use std::process::Command;
4
5#[derive(Debug, PartialEq, PartialOrd)]
9pub struct GetDeviceSpec {
10 output: PathBuf,
11}
12impl GetDeviceSpec {
13 pub fn new(output: &Path) -> Self {
14 Self {
15 output: output.to_owned(),
16 }
17 }
18
19 pub fn run(&self) -> Result<()> {
20 let mut get_device_spec = Command::new("java");
21 get_device_spec.arg("-jar");
22 if let Ok(bundletool_path) = std::env::var("BUNDLETOOL_PATH") {
23 get_device_spec.arg(bundletool_path);
24 } else {
25 return Err(Error::BundletoolNotFound);
26 }
27 get_device_spec.arg("get-device-spec");
28 get_device_spec.arg("--output").arg(&self.output);
29 get_device_spec.output_err(true)?;
30 Ok(())
31 }
32}