use std::ffi::OsString;
use std::path::PathBuf;
pub(crate) const HOME: &str = "HOME";
pub(crate) const LSP_DATA: &str = "LSP_DATA";
pub(crate) const XDG_RUNTIME_DIR: &str = "XDG_RUNTIME_DIR";
pub(crate) const XDG_CONFIG_HOME: &str = "XDG_CONFIG_HOME";
pub(crate) const PATH: &str = "PATH";
pub(crate) const SHELL: &str = "SHELL";
pub(crate) const DATA_RELEASE_API_URL: &str = "LSP_CLI_DATA_RELEASE_API_URL";
#[cfg(test)]
pub(crate) const TEST_FAKE_NPM_PROGRAM: &str = "LSP_CLI_TEST_FAKE_NPM_PROGRAM";
fn path_var(name: &str) -> Option<PathBuf> {
std::env::var_os(name).map(PathBuf::from)
}
pub(crate) fn home() -> Option<PathBuf> {
path_var(HOME)
}
pub(crate) fn lsp_data() -> Option<PathBuf> {
path_var(LSP_DATA)
}
pub(crate) fn xdg_runtime() -> Option<PathBuf> {
path_var(XDG_RUNTIME_DIR)
}
pub(crate) fn xdg_config_home() -> Option<PathBuf> {
path_var(XDG_CONFIG_HOME)
}
pub(crate) fn path() -> Option<OsString> {
std::env::var_os(PATH)
}
pub(crate) fn shell() -> Option<OsString> {
std::env::var_os(SHELL)
}
pub(crate) fn data_release_api_url() -> Option<String> {
std::env::var(DATA_RELEASE_API_URL).ok()
}
#[cfg(test)]
pub(crate) fn fake_npm_program() -> Option<OsString> {
std::env::var_os(TEST_FAKE_NPM_PROGRAM)
}