simple case working

This commit is contained in:
Rakarake 2026-03-26 13:20:05 +01:00
parent 4b2c64dafd
commit c4b6fb1fc0
5 changed files with 151 additions and 111 deletions

View file

@ -1,27 +1,27 @@
use std::{env::args, io};
use markdown::to_html;
use clap::Parser;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
/// Name of the person to greet
#[arg(short, long)]
name: String,
/// Number of times to greet
#[arg(short, long, default_value_t = 1)]
count: u8,
}
fn main() {
let args = Args::parse();
use rss::{Channel, Item, ChannelBuilder, ItemBuilder};
fn main() -> io::Result<()> {
// takes directory of markdown files as only argument, outputs
// html output into stdout (TODO make )
if let Some(dir) = std::env::args().skip(1).next() {
// get files in dir
}
//let input: String = std::fs::read_to_string(&args[1]).unwrap();
//print!("{}", to_html(&input));
let mut channel = Channel::default();
channel.title = "MDF blog huge".to_string();
channel.link = "rakarake.xyz".to_string();
channel.description = "morbius text wow".to_string();
channel.items = std::env::args().skip(1).map(|f| {
let contents = std::fs::read_to_string(f.clone())?;
let html = to_html(&contents);
// TODO get the title from the document, read other metadata
Ok(ItemBuilder::default()
.title(f)
.description(html)
.build()
)
}).collect::<Result<Vec<Item>, io::Error>>()?;
println!("{}", channel.to_string());
Ok(())
}