Skip to content

Commit

Permalink
Feat(*): Windows Support (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillKirkmanM committed Apr 30, 2023
2 parents 1bb404c + c4976b0 commit fcbd297
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ authors = ["WillKirkmanM <[email protected]>"]
[dependencies]
clap = { version = "4.2.4", features = ["derive"] }
colored = "2.0.0"
dylib = "0.0.3"
flate2 = "1.0.25"
flate2 = "1.0.26"
indicatif = "0.17.3"
reqwest = "0.11.17"
serde = { version = "1.0.160", features = ["derive"] }
Expand Down
11 changes: 10 additions & 1 deletion src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::path::Path;
use std::thread;
use std::time::Duration;
use std::fs;
use std::env;
use std::{cmp::min, fmt::Write};


Expand All @@ -17,7 +18,15 @@ use colored::Colorize;
use crate::get_path;

pub async fn download_environment(id: String) -> Result<(), Box<dyn Error>> {
let base_path = "/usr/share/sandbox/beaches/";
let base_path = match env::consts::OS {
"windows" => {
let appdata = std::env::var("appdata").unwrap();
let beaches_path = format!("{}/sandbox/beaches/", appdata);
beaches_path
}
_ => "/usr/share/sandbox/beaches/".to_string()
};

let environment_path = get_path(id.clone()).await;

let download_url = format!("https://github.com/the-sandbox-project/sandbox-templates/raw/master/{}", environment_path);
Expand Down
13 changes: 12 additions & 1 deletion src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ pub async fn open_environment(environment: String) {

let path = get_path(environment.clone()).await;
let environment_path = path.split("/").collect::<Vec<&str>>()[0].to_owned() + "/" + &environment;
let beaches_path = format!("/usr/share/sandbox/beaches/{}", environment_path);

let beaches_path = match env::consts::OS {
"windows" => {
let appdata = std::env::var("appdata").unwrap();
let beaches_path = format!("{}/sandbox/beaches/{}", appdata, environment_path);
beaches_path
}
_ => {
let beaches_path = format!("/usr/share/sandbox/beaches/{}", environment_path);
beaches_path
}
};

env::set_current_dir(beaches_path).unwrap();
Command::new(editor)
Expand Down

0 comments on commit fcbd297

Please sign in to comment.