Skip to content

Commit

Permalink
add version option to install binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Apr 12, 2024
1 parent c10d04a commit f67d723
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ pub enum Sdk {
/// Force platform to install binaries for
#[clap(long, short)]
platform: Option<String>,
/// Specify version to install
#[clap(long, short)]
version: Option<String>,
},

/// Uninstall SDK
Expand Down Expand Up @@ -427,14 +430,25 @@ fn switch_to_tag(config: &mut Config, repo: &Repository) {
done!("Updated head to v{}", latest_version.unwrap());
}

fn install_binaries(config: &mut Config, platform: Option<String>) {
fn install_binaries(config: &mut Config, platform: Option<String>, version: Option<String>) {
let release_tag: String;
let target_dir: PathBuf;
if config.sdk_nightly {
info!("Installing nightly binaries");
release_tag = "nightly".into();
target_dir = Config::sdk_path().join("bin/nightly");
} else {
}
else if version.is_some() {
let ver = Version::parse(version.as_deref().unwrap())
.nice_unwrap("Invalid version specified");
info!("Installing binaries for {}", ver);

release_tag = format!("v{}", ver);
let mut stripped_ver = ver.clone();
stripped_ver.pre = Prerelease::EMPTY;
target_dir = Config::sdk_path().join(format!("bin/{}", stripped_ver));
}
else {
let ver = get_version();
info!("Installing binaries for {}", ver);
release_tag = format!("v{}", ver);
Expand Down Expand Up @@ -638,6 +652,6 @@ pub fn subcommand(config: &mut Config, cmd: Sdk) {
Sdk::SetPath { path, r#move } => set_sdk_path(path, r#move),
Sdk::Update { branch } => update(config, branch),
Sdk::Version => info!("Geode SDK version: {}", get_version()),
Sdk::InstallBinaries { platform } => install_binaries(config, platform),
Sdk::InstallBinaries { platform, version } => install_binaries(config, platform, version),
}
}

0 comments on commit f67d723

Please sign in to comment.