pub fn load_user_templates(
cli_templates: Option<PathBuf>,
config: &BhtuneConfig,
xdg_config_home: Option<&str>,
home: Option<&str>,
appdata: Option<&str>,
is_windows: bool,
) -> Result<Option<Vec<DcsTemplate>>>Expand description
Resolve and load the user-supplied DCS/PLC template catalog (template-user-catalog):
--templates / BHTUNE_TEMPLATES (already folded into cli_templates by clap’s env
attribute) / the config file’s templates key, or else the platform’s auto-discovered
templates.toml next to bhtune.toml (see templates_path_from) – CLI flag > env var > config file > platform default, the same precedence chain as every other bhtune
setting.
Returns Ok(None) when no catalog applies at all: nothing was requested explicitly and
no file exists at the auto-discovered default path – the common case, since most
installs never create this file. A path named explicitly (by any of the first three
tiers) that doesn’t exist is a hard error, exactly mirroring bhtune.toml itself
(load_config_file’s missing_is_error); a file that exists (whichever tier it came
from) but fails to parse as TOML or fails DcsTemplate::validate() is always a hard
error naming the file and the problem – a malformed catalog should never be silently
ignored. Parsing and validating are both handled by
bhtune_core::template::parse_catalog, so this function does no TOML-shape or
cross-field checking of its own.