diff --git a/Cargo.lock b/Cargo.lock index dc98303..92a200b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,6 +46,7 @@ name = "forgebuild" version = "0.2.0" dependencies = [ "glob", + "home", "hostname", "lazy_static", "serde", @@ -77,6 +78,15 @@ dependencies = [ "libc", ] +[[package]] +name = "home" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654" +dependencies = [ + "winapi", +] + [[package]] name = "hostname" version = "0.3.1" diff --git a/Cargo.toml b/Cargo.toml index 38dffbb..d9c4e6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,3 +16,5 @@ serde_json = "1.0" structopt = "0.3" # Debug Context for translations serde = { version = "1.0", features = ["derive"] } +# Detect home folder +home = "0.5.3" diff --git a/src/cli.rs b/src/cli.rs index 793671a..b88050b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,6 +1,7 @@ use std::env; use std::path::PathBuf; use structopt::StructOpt; +use home::home_dir; #[derive(Debug, StructOpt)] #[structopt( @@ -26,7 +27,7 @@ impl Cli { // Returns an error when the path doesn't exist PathBuf::from(basedir) } else { - let mut home_path = PathBuf::from(env::var("HOME").expect("No $HOME in env")); + let mut home_path = home_dir().expect("No HOME folder found."); home_path.push(".forgebuild"); home_path }