You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.0 KiB
Rust
55 lines
1.0 KiB
Rust
use crate::{PathBuf, env, UserDirs};
|
|
|
|
static PROJECT_CONFIG_FILE_NAME: &str = "igloo.toml";
|
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
|
pub struct IglooEnv
|
|
{
|
|
// Current Working Directory
|
|
pub cwd: PathBuf,
|
|
// Home Directory
|
|
pub hd: PathBuf,
|
|
// ESF Directory
|
|
pub esfd: PathBuf,
|
|
}
|
|
|
|
impl IglooEnv
|
|
{
|
|
pub fn get_env() -> IglooEnv
|
|
{
|
|
IglooEnv
|
|
{
|
|
cwd: match env::current_dir()
|
|
{
|
|
Ok(v) => v,
|
|
Err(e) => panic!(),
|
|
},
|
|
hd: match UserDirs::new()
|
|
{
|
|
Some(v) => v.home_dir().to_owned(),
|
|
None =>
|
|
{
|
|
println!("Error: Failed to get home directory.\n\
|
|
This should never happen. Exiting...");
|
|
std::process::exit(1);
|
|
}
|
|
},
|
|
esfd: match std::env::var("ESF_DIR")
|
|
{
|
|
Ok(v) =>
|
|
{
|
|
std::path::PathBuf::from(&v.to_owned())
|
|
}
|
|
Err(e) =>
|
|
{
|
|
// Note : Need to change new to return actual errors
|
|
// instead of exiting early
|
|
println!("Error: $ESF_DIR not defined as an environment\
|
|
variable -- {:?}", e);
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|