24 lines
662 B
Rust
24 lines
662 B
Rust
use crate::error::{AppError, SafeError};
|
|
use directories::ProjectDirs;
|
|
use std::path::PathBuf;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct AppPaths {
|
|
config_dir: PathBuf,
|
|
}
|
|
impl AppPaths {
|
|
pub fn discover() -> Result<Self, AppError> {
|
|
let dirs = ProjectDirs::from("com", "azure", "azure-database-tui").ok_or_else(|| {
|
|
AppError(SafeError::configuration(
|
|
"Application configuration directory is unavailable",
|
|
))
|
|
})?;
|
|
Ok(Self {
|
|
config_dir: dirs.config_dir().to_path_buf(),
|
|
})
|
|
}
|
|
pub fn profiles_path(&self) -> PathBuf {
|
|
self.config_dir.join("profiles.json")
|
|
}
|
|
}
|