mirror of
https://codeberg.org/postscriptum/snac2nex.git
synced 2026-03-31 21:25:28 +00:00
reorganize template format members
This commit is contained in:
parent
475e23c774
commit
25186136bc
4 changed files with 104 additions and 118 deletions
14
src/nex.rs
14
src/nex.rs
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue