Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Colour & Docs Update #5

Merged
merged 6 commits into from
Apr 29, 2023
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
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"

[dependencies]
clap = { version = "4.2.4", features = ["derive"] }
colored = "2.0.0"
dylib = "0.0.3"
flate2 = "1.0.25"
indicatif = "0.17.3"
Expand All @@ -15,3 +16,8 @@ serde = { version = "1.0.160", features = ["derive"] }
serde_yaml = "0.9.21"
tar = "0.4.38"
tokio = { version = "1.28.0", default_features = false, features = ["full"] }

[profile.release]
strip = true
lto = true
codegen-units = 1
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct EditorConfig {

pub fn read_config_file() -> Result<Config, String> {
match env::consts::OS {
"linux" => {
"linux" | "darwin" => {
let config = get_config_linux().unwrap();
Ok(config)
},
Expand Down
3 changes: 2 additions & 1 deletion src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use reqwest::Client;
use flate2::read::GzDecoder;
use tar::Archive;
use indicatif::{ProgressBar, ProgressState, ProgressStyle};
use colored::Colorize;

use crate::get_path;

Expand Down Expand Up @@ -63,7 +64,7 @@ pub async fn download_environment(id: String) -> Result<(), Box<dyn Error>> {
archive.unpack(&unzip_path)?;
fs::remove_file(&download_path)?;

println!("Installed {}! Test it out with: sandbox --new {}", id, id)
println!("Installed {}! Test it out with: sandbox --new {}", id.bright_green(), id.bright_green())
}
Ok(())
}
Expand Down
6 changes: 4 additions & 2 deletions src/install.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
use std::path::Path;

use colored::Colorize;

use crate::{get_path, id_is_valid, download::download_environment};

pub async fn install_environment(id: String) {
if id_is_valid(id.clone()).await {
if in_system(id.clone()).await {
println!("You already have {} installed on your system!", id);
println!("You already have {} installed on your system!", id.bright_green());
} else {
download_environment(id.clone()).await.unwrap();
}
} else {
println!("The environment {} does not exist!", id)
println!("The environment ({}) does {} exist!", id.bright_green(), "not".red())
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/new.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
use crate::id_is_valid;
use crate::environment::open_environment;
use crate::install::in_system;

use colored::Colorize;

pub async fn create_new_environment(environment: String) {
if id_is_valid(environment.clone()).await {
open_environment(environment).await
if in_system(environment.clone()).await {
open_environment(environment).await
} else {
println!("You do {} have {} installed! Install it with:\nsandbox --install {}", "not".red(), environment.bright_green(), environment.bright_green())
}
} else {
println!("The environment {} does not exist?", environment)
println!("The environment {} does {} exist... You can search for an environment with\nsandbox --search {}", environment.bright_green(), "not".red(), environment.bright_green())
}
}
12 changes: 7 additions & 5 deletions src/search.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use crate::install::in_system;
use crate::get_templates_mapping;

use colored::Colorize;

pub async fn search(query: String) {
let matching_environments_exist = search_environment(query.clone()).await;

if matching_environments_exist {
println!("\nEnvironments That Match Query {}", query);
println!("\nEnvironments That Match Query {}", query.bright_green());
println!("Install any of these with sandbox install <ENVIRONMENT>")
} else {
println!("No Environments Found for Query: {}", query)
println!("{} Environments Found for Query: {}", "No".red(), query.bright_green())
}
}

Expand All @@ -27,13 +29,13 @@ pub async fn search_environment(query: String) -> bool {
let id = project_id.as_str().unwrap().to_string();

let installed = match in_system(id.clone()).await {
true => "✅",
false => "❌"
true => "✅".bright_green(),
false => "❌".red()
};

matching_environments_exist = true;

println!(" {} {} ({}) - {}", installed, title, id, description);
println!(" {} {} ({}) - {}", installed, title, id.blue(), description);

}
}
Expand Down