Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crossbundle/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ log = "0.4"
fs_extra = "1.2"
dirs = "4.0.0"
dunce = "1.0"
ureq = "2.4.0"
ureq = { version = "2.4.0", features = ["tls"] }
cargo = "0.63.1"
cargo-util = "0.2.0"

Expand Down
23 changes: 16 additions & 7 deletions crossbundle/cli/src/commands/install/bundletool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::path::PathBuf;
#[derive(Parser, Clone, Debug, Default)]
pub struct BundletoolInstallCommand {
/// Required. Version of download bundletool. For example:
/// --version 1.8.2
#[clap(long, short, default_value = "1.8.2")]
/// --version 1.11.0
#[clap(long, short, default_value = "1.11.0")]
version: String,
/// Path to install bundletool. By default bundletool will be downloaded and saved in home directory
#[clap(long, short)]
Expand All @@ -20,14 +20,15 @@ pub struct BundletoolInstallCommand {
impl BundletoolInstallCommand {
/// Download and install bundletool to provided or default path
pub fn install(&self, config: &Config) -> crate::error::Result<()> {
config.status("Installing bundletool")?;
let home_dir = default_file_path(self.file_name())?
.parent()
.unwrap()
.to_owned();
if !self.force {
for bundletool in
std::fs::read_dir(default_file_path(self.file_name())?.parent().unwrap())?
{
for bundletool in std::fs::read_dir(&home_dir)? {
let installed_bundletool = bundletool?.path();
if installed_bundletool.ends_with(self.file_name()) {
config.status("You have installed budletool on your system already")?;
config.status("You have installed budletool on your system already. Use `--force` command to overwrite.")?;
return Ok(());
}
}
Expand All @@ -38,9 +39,17 @@ impl BundletoolInstallCommand {
let download_url_str = String::from(download_url.to_str().unwrap());

if let Some(install_path) = &self.path {
config.status_message(
format!("{} installing into", self.file_name()),
install_path.to_string_lossy(),
)?;
let jar_path = install_path.join(self.file_name());
download_to_file(&download_url_str, &jar_path)?;
} else {
config.status_message(
format!("{} installing into", self.file_name()),
home_dir.to_string_lossy(),
)?;
let default_jar_path = default_file_path(self.file_name())?;
download_to_file(&download_url_str, &default_jar_path)?;
};
Expand Down
10 changes: 5 additions & 5 deletions crossbundle/cli/src/commands/install/command_line_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ pub struct CommandLineToolsInstallCommand {
/// Assign path to install command line tools
#[clap(long, short)]
pub install_path: Option<PathBuf>,
/// Remove corrupted zip archive if installation was aborted
/// Force install command line tools even if found or corrupted.
#[clap(long, short)]
pub remove_zip: bool,
pub force: bool,
}

impl CommandLineToolsInstallCommand {
/// Download command line tools zip archive and extract it in specified sdk root directory
pub fn install(&self, config: &Config) -> crate::error::Result<()> {
if self.remove_zip {
if self.force {
remove(vec![default_file_path(self.file_name())?])?;
}

Expand All @@ -33,7 +33,7 @@ impl CommandLineToolsInstallCommand {
let file_path = default_file_path(self.file_name())?;

config.status_message(
"Downloading command line tools zip archive into",
format!("Downloading {} into", self.file_name()),
&file_path.parent().unwrap().to_str().unwrap(),
)?;
self.download_and_save_file(command_line_tools_download_url, &file_path)?;
Expand Down Expand Up @@ -62,7 +62,7 @@ impl CommandLineToolsInstallCommand {

/// Return command line tools zip archive for defined operating system
fn file_name(&self) -> String {
format!("commandlinetools-{}-8092744_latest.zip", OS_TAG)
format!("commandlinetools-{}-8512546_latest.zip", OS_TAG)
}

/// Check home directory for zip file. If it doesn't exists download zip file and save it in the directory
Expand Down