ITAJ6L444PCEX6QTW6FDC7OU4NDM5IHY2GYSM2SMVAB3JYSDOYJQC
ZAHWS7ZRQ5534BMB4ILIZIGFS6F4RLC2IM64GH2IBN5CPSXHHVRAC
YQSLDBVSLMXMWYHDASV2QOSYZMMLV2T2QT2IWJT6WYWQKOL2MKFQC
F2QYIRKBFYFWSTB7Z5CNGSZVYI6XQO3MHPUHJLBHPGLIOG7UNVNQC
KUHZYHYVA5XG437YCSHDCTPTAYNQD6QUO77I4UWOWGFLWMEVCPNQC
TUBVSWW3OQX2OJKF2F5ACCPL3G6U6SNJQ3EWOSPBCV6EIZPM2LMAC
FTI67CGF4MMPDFA6YJN6UKOADQLFAECKGYPTWSPSALVQK76BJMJAC
I5WVRUHGAQGWFZGX7YBKCGQKLHXZHZTCBWFIUCXVGY2WVFB77VQQC
fn project_dir() -> ProjectDirs {
ProjectDirs::from("com", "histdb-rs", "histdb-rs")
.expect("getting project dirs should never fail")
#[derive(Error, Debug)]
pub enum Error {
#[error("can not get base directories")]
BaseDirectory,
#[error("can not get runtime dir. make sure $XDG_RUNTIME_DIR is set")]
RuntimeDir,
#[error("can not get project dirs")]
ProjectDirs,
}
fn get_default_or_fail<T>(func: fn() -> Result<T, Error>) -> T {
match func() {
Ok(s) => s,
Err(e) => {
error!("{}", e);
std::process::exit(1);
}
}
fn default_data_dir() -> String {
let project_dir = project_dir();
fn project_dir() -> Result<ProjectDirs, Error> {
ProjectDirs::from("com", "histdb-rs", "histdb-rs").ok_or(Error::ProjectDirs)
}
fn default_data_dir() -> Result<String, Error> {
let project_dir = project_dir()?;
fn default_histdb_sqlite_path() -> String {
let base_dirs = directories::BaseDirs::new().expect("getting basedirs should never fail");
fn default_histdb_sqlite_path() -> Result<String, Error> {
let base_dirs = directories::BaseDirs::new().ok_or(Error::BaseDirectory)?;
// TODO: Sometimes getting the runtime dir can fail maybe find a good fallback path and use
// that instead. Or find a good way to propagate the error to structopt.
.expect("getting the runtime dir should never fail")
.ok_or(Error::RuntimeDir)?