Skip to content

Commit

Permalink
Add conditional compilation for initalize_config function since its u…
Browse files Browse the repository at this point in the history
…nix specific
  • Loading branch information
humblepenguinn committed Apr 8, 2024
1 parent 245e687 commit 01464b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/bin/envio/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ use colored::Colorize;
use semver::Version;

use clap_app::ClapApp;
use utils::initalize_config;
use version::get_latest_version;

#[cfg(target_family = "unix")]
use utils::initalize_config;

fn main() {
color_eyre::install().unwrap();

Expand All @@ -35,6 +37,7 @@ fn main() {

let args = ClapApp::parse();

#[cfg(target_family = "unix")]
if let Err(e) = initalize_config() {
println!("{}: {}", "Error".red(), e);
}
Expand Down
24 changes: 15 additions & 9 deletions src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,30 @@ impl From<HashMap<String, String>> for EnvVec {
}

/// Convert a `EnvVec` to a `Vec<Env>` or a `HashMap<String, String>`
impl Into<Vec<Env>> for EnvVec {
fn into(self) -> Vec<Env> {
self.envs
impl From<EnvVec> for Vec<Env> {
fn from(val: EnvVec) -> Self {
val.envs
}
}

impl Into<HashMap<String, String>> for EnvVec {
fn into(self) -> HashMap<String, String> {
impl From<EnvVec> for HashMap<String, String> {
fn from(val: EnvVec) -> Self {
let mut envs = HashMap::new();

for e in self.envs {
for e in val.envs {
envs.insert(e.name, e.value);
}

envs
}
}

impl Default for EnvVec {
fn default() -> Self {
Self::new()
}
}

impl EnvVec {
pub fn new() -> EnvVec {
EnvVec { envs: Vec::new() }
Expand Down Expand Up @@ -427,9 +433,9 @@ impl Profile {
};

match bincode::deserialize(&content) {
Ok(profile) => return Ok(profile),
Err(e) => return Err(Error::Deserialization(e.to_string())),
};
Ok(profile) => Ok(profile),
Err(e) => Err(Error::Deserialization(e.to_string())),
}
}

/// Check to see if a profile with the given name exists on the system
Expand Down

0 comments on commit 01464b9

Please sign in to comment.