use std::env;
use log::debug;
const ENV_PMBS_DIR_ETC: &'static str = "PMBS_DIR_ETC";
const DEFAULT_PMBS_DIR_ETC: &'static str = "/etc/pmbs";
const ENV_PMBS_DIR_LOG: &'static str = "PMBS_DIR_LOG";
const DEFAULT_PMBS_DIR_LOG: &'static str = "/var/log/pmbs";
const ENV_PMBS_BIN_BTRFS: &'static str = "PMBS_BIN_BTRFS";
const DEFAULT_PMBS_BIN_BTRFS: &'static str = "btrfs";
#[derive(Debug, Clone)]
pub struct ConfigEnv {
pub dir_etc: String,
pub dir_log: String,
pub bin_btrfs: String,
}
impl ConfigEnv {
pub fn new() -> Self {
Self {
dir_etc: env::var(ENV_PMBS_DIR_ETC).unwrap_or(DEFAULT_PMBS_DIR_ETC.into()),
dir_log: env::var(ENV_PMBS_DIR_LOG).unwrap_or(DEFAULT_PMBS_DIR_LOG.into()),
bin_btrfs: env::var(ENV_PMBS_BIN_BTRFS).unwrap_or(DEFAULT_PMBS_BIN_BTRFS.into()),
}
}
}
pub fn get_env_config() -> ConfigEnv {
let c = ConfigEnv::new();
debug!("config {:?}", c);
c
}