use std::path::PathBuf;
pub fn jobs_dir() -> PathBuf {
jobs_dir_from_home(dirs::home_dir())
}
pub(crate) fn jobs_dir_from_home(home: Option<PathBuf>) -> PathBuf {
home.unwrap_or_else(|| PathBuf::from("."))
.join(".config")
.join("moadim")
.join("jobs")
}
pub fn handlers_dir() -> PathBuf {
handlers_dir_from_home(dirs::home_dir())
}
pub(crate) fn handlers_dir_from_home(home: Option<PathBuf>) -> PathBuf {
home.unwrap_or_else(|| PathBuf::from("."))
.join(".config")
.join("moadim")
.join("handlers")
}
pub fn job_dir(id: &str) -> PathBuf {
jobs_dir().join(id)
}
pub fn job_toml_path(id: &str) -> PathBuf {
job_dir(id).join("job.toml")
}
pub fn job_local_toml_path(id: &str) -> PathBuf {
job_dir(id).join("job.local.toml")
}
pub fn job_gitignore_path(id: &str) -> PathBuf {
job_dir(id).join(".gitignore")
}
pub fn job_log_path(id: &str) -> PathBuf {
job_dir(id).join("job.local.log")
}
pub fn routines_dir() -> PathBuf {
routines_dir_from_home(dirs::home_dir())
}
pub(crate) fn routines_dir_from_home(home: Option<PathBuf>) -> PathBuf {
home.unwrap_or_else(|| PathBuf::from("."))
.join(".config")
.join("moadim")
.join("routines")
}
pub fn routine_dir(id: &str) -> PathBuf {
routines_dir().join(id)
}
pub fn routine_toml_path(id: &str) -> PathBuf {
routine_dir(id).join("routine.toml")
}
pub fn routine_prompt_path(id: &str) -> PathBuf {
routine_dir(id).join("prompt.txt")
}
pub fn routine_gitignore_path(id: &str) -> PathBuf {
routine_dir(id).join(".gitignore")
}
pub fn routine_script_path(id: &str) -> PathBuf {
routine_dir(id).join("run.sh")
}
pub fn agents_dir() -> PathBuf {
agents_dir_from_home(dirs::home_dir())
}
pub(crate) fn agents_dir_from_home(home: Option<PathBuf>) -> PathBuf {
home.unwrap_or_else(|| PathBuf::from("."))
.join(".config")
.join("moadim")
.join("agents")
}
pub fn agent_toml_path(name: &str) -> PathBuf {
agents_dir().join(format!("{name}.toml"))
}
pub fn config_dir() -> PathBuf {
config_dir_from_home(dirs::home_dir())
}
pub(crate) fn config_dir_from_home(home: Option<PathBuf>) -> PathBuf {
home.unwrap_or_else(|| PathBuf::from("."))
.join(".config")
.join("moadim")
}
pub fn pid_file() -> PathBuf {
config_dir().join("moadim.pid")
}
pub fn daemon_log_file() -> PathBuf {
config_dir().join("daemon.log")
}
pub fn moadim_home() -> PathBuf {
moadim_home_from_home(dirs::home_dir())
}
pub(crate) fn moadim_home_from_home(home: Option<PathBuf>) -> PathBuf {
home.unwrap_or_else(|| PathBuf::from(".")).join(".moadim")
}
pub fn workbenches_dir() -> PathBuf {
moadim_home().join("workbenches")
}
#[cfg(test)]
mod mod_tests;