Layout entries

This commit is contained in:
Joscha 2021-12-11 20:45:55 +01:00
parent d6d225c098
commit 44bcd5712d
6 changed files with 204 additions and 50 deletions

View file

@ -3,44 +3,10 @@
#![warn(clippy::all)]
#![warn(clippy::use_self)]
use std::path::PathBuf;
use chrono::NaiveDate;
use structopt::StructOpt;
use crate::eval::{DateRange, EntryMode};
use crate::files::Files;
mod cli;
mod eval;
mod files;
#[derive(Debug, StructOpt)]
pub struct Opt {
#[structopt(parse(from_os_str))]
file: PathBuf,
}
fn main() -> anyhow::Result<()> {
let opt = Opt::from_args();
let mut files = Files::load(&opt.file)?;
println!("{}", files.now().format("%F %T %Z"));
let range = DateRange::new(
NaiveDate::from_ymd(2021, 1, 1),
NaiveDate::from_ymd(2022, 12, 31),
)
.unwrap();
for entry in files.eval(EntryMode::Relevant, range)? {
let title = files.command(entry.source).title();
if let Some(dates) = entry.dates {
println!("{:36} - {}", format!("{}", dates), title);
} else {
println!("{:36} - {}", "undated", title);
}
}
files.mark_all_dirty();
files.save()?;
Ok(())
cli::run()
}