mirror of
https://github.com/YGGverse/flarumdown.git
synced 2026-03-31 08:45:28 +00:00
implement index file option
This commit is contained in:
parent
6b07499d10
commit
1828a99955
2 changed files with 15 additions and 0 deletions
|
|
@ -16,4 +16,8 @@ pub struct Config {
|
||||||
/// * keep empty to export all
|
/// * keep empty to export all
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub filter_tag: Vec<String>,
|
pub filter_tag: Vec<String>,
|
||||||
|
|
||||||
|
/// Generate index file with given name
|
||||||
|
#[arg(short, long)]
|
||||||
|
pub index: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
src/main.rs
11
src/main.rs
|
|
@ -96,6 +96,17 @@ fn main() -> Result<()> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(index) = config.index {
|
||||||
|
let mut file = File::create_new({
|
||||||
|
let mut path = PathBuf::from(&config.target);
|
||||||
|
path.push(format!("{}.md", index.trim_end_matches(".md")));
|
||||||
|
path
|
||||||
|
})?;
|
||||||
|
for discussion in &discussions {
|
||||||
|
file.write_all(format!("* [{}]({}.md)\n", discussion.title, discussion.id).as_bytes())?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for discussion in discussions {
|
for discussion in discussions {
|
||||||
let mut file = File::create_new({
|
let mut file = File::create_new({
|
||||||
let mut path = PathBuf::from(&config.target);
|
let mut path = PathBuf::from(&config.target);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue