Removes some hacks that were being used to get the config directory based on the config file.
HGJETVANHD25AZLOPYYEXCMLZHZWZ2NAKI33XQ7F43XM3UZVQNOQC SXEYMYF7P4RZMZ46WPL4IZUTSQ2ATBWYZX7QNVMS3SGOYXYOHAGQC VL7ZYKHBPKLNY5SA5QBW56SJ7LBBCKCGV5UAYLVF75KY6PPBOD4AC 4KJ45IJLTIE35KQZUSFMFS67RNENG4P2FZMKMULJLGGYMKJUVRSQC LZOGKBJXRQJKXHYNNENJFGNLP5SHIXGSV6HDB7UVOP7FSA5EUNCQC QWIYNMI5SOTLRPYE4O3AG7R75JXM2TB3ZADU646PG6ACPBGSYUYAC Z4PPQZUGHT5F5VFFBQBIW2J3OLHP4SF33QMT6POFCX6JS7L6G7GQC YW6NICQV5LF4V2G77F2RG2ICODTQ2CKIEVBFIQEDATL5I5PFVRKQC HM6QW3CYVZVXOM2K3OT7SQFQGJG3GCDLNYIYAUDEVSJCVCSUZ4CQC let global_config = match Global::read_contents(&global_config_path) {Ok(contents) => {// Parse the config (and make sure it's valid!)let global_config = Global::parse_contents(&global_config_path, &contents)?;// Add the configuration layer as a stringlayers = layers.merge(Toml::string(&contents));
let global_config = match Global::config_file() {Some(global_config_path) => match Global::read_contents(&global_config_path) {Ok(contents) => {// Parse the config (and make sure it's valid!)let global_config = Global::parse_contents(&global_config_path, &contents)?;// Add the configuration layer as a stringlayers = layers.merge(Toml::string(&contents));
}/// Select which configuration directory to usepub fn global_config_directory() -> Option<PathBuf> {// 1. $PIJUL_CONFIG_DIR/std::env::var("PIJUL_CONFIG_DIR").ok().map(PathBuf::from).map(|directory| directory.join(CONFIG_FILE))// 2. ~/.config/pijul/.or_else(|| match dirs_next::config_dir() {Some(global_config_dir) => Some(global_config_dir.join(CONFIG_DIR)),None => None,})// 3. ~/.pijulconfig/.or_else(|| match dirs_next::home_dir() {Some(home_dir) => Some(home_dir.join(CONFIG_DIR)),None => None,})
// 1. PIJUL_CONFIG_DIR environment variablestd::env::var("PIJUL_CONFIG_DIR").ok().map(PathBuf::from)// 2. ~/.config/pijul/config.toml.or_else(|| match dirs_next::config_dir() {Some(config_dir) => {let config_path = config_dir.join(CONFIG_DIR).join(CONFIG_FILE);match config_path.exists() {true => Some(config_path),false => None,}}None => None,})// 3. ~/.pijulconfig.or_else(|| match dirs_next::home_dir() {Some(home_dir) => {let config_path = home_dir.join(GLOBAL_CONFIG_FILE);match config_path.exists() {true => Some(config_path),false => None,}}None => None,})
// {config_directory}/config.tomlcrate::global_config_directory().map(|config_directory| config_directory.join(CONFIG_FILE))