use crate::config::CFG;
use crate::settings::ARGS;
use tpnote_lib::template::TemplateKind;
pub(crate) fn template_kind_filter(template_kind: TemplateKind) -> TemplateKind {
match template_kind {
TemplateKind::FromTextFile => {
if (ARGS.add_header || CFG.arg_default.add_header)
&& !CFG.arg_default.no_filename_sync
&& !ARGS.no_filename_sync
{
template_kind
} else {
log::info!(
"Not adding header to text file: \
`add_header` is not enabled or `no_filename_sync`",
);
log::debug!("Changing the template to \"TemplateKind::None\"");
TemplateKind::None
}
}
TemplateKind::SyncFilename => {
if ARGS.no_filename_sync {
log::info!("Filename synchronisation disabled with the flag: `--no-filename-sync`",);
log::debug!("Changing the template to \"TemplateKind::None\"");
TemplateKind::None
} else if CFG.arg_default.no_filename_sync {
log::info!(
"Filename synchronisation disabled with the configuration file \
variable: `[arg_default] no_filename_sync = true`",
);
log::debug!("Changing the template to \"TemplateKind::None\"");
TemplateKind::None
} else {
template_kind
}
}
_ => template_kind,
}
}