diff --git a/src/sdk.rs b/src/sdk.rs index 6cd9317..25ba5db 100644 --- a/src/sdk.rs +++ b/src/sdk.rs @@ -65,6 +65,9 @@ pub enum Sdk { /// Force platform to install binaries for #[clap(long, short)] platform: Option, + /// Specify version to install + #[clap(long, short)] + version: Option, }, /// Uninstall SDK @@ -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) { +fn install_binaries(config: &mut Config, platform: Option, version: Option) { 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); @@ -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), } }