reorganize template format members

This commit is contained in:
postscriptum 2025-07-04 15:23:35 +03:00
parent 475e23c774
commit 25186136bc
4 changed files with 104 additions and 118 deletions

View file

@ -1,12 +1,11 @@
mod attachment;
mod format;
pub mod response;
pub mod source;
mod template;
use anyhow::{Result, bail};
use attachment::Attachment;
use chrono::{DateTime, Utc};
use format::Format;
use response::{Clean, Sync, change::Change};
use source::Source;
use std::{
@ -15,13 +14,14 @@ use std::{
path::PathBuf,
str::FromStr,
};
use template::Template;
pub struct Nex {
attachment: Attachment,
filename: String,
format: Format,
is_cleanup: bool,
is_debug: bool,
template: Template,
users: HashMap<String, PathBuf>,
}
@ -48,13 +48,13 @@ impl Nex {
fs::create_dir_all(&p)?;
users.insert(u.clone(), p);
}
// init document format
let format = Format::init(&filename, pattern, time_format);
// init document template formatter
let template = Template::init(&filename, pattern, time_format);
Ok(Self {
attachment: Attachment::init(attachment_mode)?,
filename,
format,
template,
is_cleanup,
is_debug,
users,
@ -154,7 +154,7 @@ impl Nex {
};
fs::write(
&f,
self.format.to_string(
self.template.build(
updated,
content,
link,