implement index file option

This commit is contained in:
yggverse 2026-03-19 06:45:49 +02:00
parent 6b07499d10
commit 1828a99955
2 changed files with 15 additions and 0 deletions

View file

@ -16,4 +16,8 @@ pub struct Config {
/// * keep empty to export all
#[arg(short, long)]
pub filter_tag: Vec<String>,
/// Generate index file with given name
#[arg(short, long)]
pub index: Option<String>,
}

View file

@ -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 {
let mut file = File::create_new({
let mut path = PathBuf::from(&config.target);