pub mod cache;
pub mod check;
pub mod config;
pub mod data;
pub mod graph;
pub mod input;
pub mod merge;
pub mod plugin;
pub mod simplify;
pub mod testing;
pub type HandlerResult = Result<i32, Box<dyn std::error::Error>>;
use foch::input::{Config, InputSource};
use std::path::{Path, PathBuf};
pub fn resolve_input_source(
explicit: Option<&Path>,
config: &Config,
) -> Result<InputSource, String> {
if let Some(path) = explicit {
return Ok(InputSource::from_path(path.to_path_buf()));
}
let paradox = config.paradox_data_path.as_ref().ok_or_else(|| {
"no <PLAYSET_PATH> given and `paradox_data_path` is not configured; either pass a path \
explicitly or run `foch config set --paradox-data-path <dir>` so foch can default to the \
launcher's `dlc_load.json` in that directory"
.to_string()
})?;
let candidate = paradox.join("dlc_load.json");
if !candidate.is_file() {
return Err(format!(
"no <PLAYSET_PATH> given and `{}` does not exist; pass an explicit playset path or \
launch the Paradox launcher once to write `dlc_load.json`",
candidate.display()
));
}
Ok(InputSource::DlcLoad(candidate))
}
pub fn resolve_playset_path(explicit: Option<&Path>, config: &Config) -> Result<PathBuf, String> {
Ok(resolve_input_source(explicit, config)?.path().to_path_buf())
}