use crate::constants::*;
use std::path::PathBuf;
use directories::ProjectDirs;
fn project_directory() -> Option<ProjectDirs> {
ProjectDirs::from("com", "akarsh", "leetui")
}
pub fn get_data_dir() -> PathBuf {
project_directory()
.map(|proj| proj.data_local_dir().to_path_buf())
.unwrap_or_else(|| PathBuf::from(".leetcode-tui"))
}
pub fn get_config_dir() -> PathBuf {
project_directory()
.map(|proj| proj.config_dir().to_path_buf())
.unwrap_or_else(|| PathBuf::from(".leetcode-tui"))
}
pub fn get_config_file_path() -> PathBuf {
get_config_dir().join("config.toml")
}
pub(crate) fn get_solutions_dir_path() -> PathBuf {
get_data_dir().join("solutions")
}
pub(crate) fn get_default_database_file_path() -> PathBuf {
get_data_dir().join("questions.db")
}
pub fn version() -> String {
let author = clap::crate_authors!();
let commit_hash = GIT_COMMIT_HASH.get().unwrap().clone();
let config_dir_path = get_config_dir().display().to_string();
let data_dir_path = get_data_dir().display().to_string();
format!(
"\
{commit_hash}
Authors: {author}
Config directory: {config_dir_path}
Data directory: {data_dir_path}"
)
}