Skip to content

Commit

Permalink
First cut at weekly is done.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmadrid committed Jan 4, 2023
1 parent 639d6b6 commit c723d14
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 198 deletions.
194 changes: 22 additions & 172 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
argh = "0.1.4"
chrono = "0.4.19"
lazy_static = "1.4.0"
printpdf = "0.3.4"
printpdf = "0.5.3"
thiserror = "1.0.30"

[[bin]]
Expand Down
19 changes: 12 additions & 7 deletions src/bin/daily.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ struct Args {
// TODO: try to unify args across apps.
// TODO: these arguments are kind of ugly. Fix them.
/// optional start date
#[argh(option, short='s')]
#[argh(option, short = 's')]
start_date: Option<NaiveDate>,

/// optional end date
#[argh(option, short='e')]
#[argh(option, short = 'e')]
end_date: Option<NaiveDate>,
}

Expand All @@ -40,9 +40,15 @@ mod data {
pub days: Option<HashSet<Weekday>>,
}

fn some_days<const N: usize>(days: [Weekday; N]) -> Option<HashSet<Weekday>> { Some(days.iter().copied().collect()) }
fn one_day(day: Weekday) -> Option<HashSet<Weekday>> { some_days([day]) }
fn weekdays_only() -> Option<HashSet<Weekday>> { some_days([Mon, Tue, Wed, Thu, Fri]) }
fn some_days<const N: usize>(days: [Weekday; N]) -> Option<HashSet<Weekday>> {
Some(days.iter().copied().collect())
}
fn one_day(day: Weekday) -> Option<HashSet<Weekday>> {
some_days([day])
}
fn weekdays_only() -> Option<HashSet<Weekday>> {
some_days([Mon, Tue, Wed, Thu, Fri])
}

lazy_static! {
pub static ref TASKS: Vec<DailyTask<'static>> = {
Expand Down Expand Up @@ -318,8 +324,7 @@ fn main() {
if let Err(err) = main_func(&args.start_date.unwrap(), &args.end_date) {
eprintln!("Error: {:?}", err);
}
}
else if args.dates.is_empty() {
} else if args.dates.is_empty() {
if let Err(err) = main_func(&weekly::today(), &None) {
eprintln!("Error: {:?}", err);
}
Expand Down
Loading

0 comments on commit c723d14

Please sign in to comment.