Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.3 KiB

  1. #!/usr/bin/env perl
  2. =pod
  3. =head1 NAME
  4. notes-calendar - show calendar entries for a given date, in context of my notes
  5. =head1 SYNOPSIS
  6. # Show calendar entries for 2021-11-21
  7. notes calendar 2021-11-21
  8. =head1 AUTHOR
  9. Brennen Bearnes
  10. =cut
  11. use warnings;
  12. use strict;
  13. use 5.10.0;
  14. use Cwd;
  15. use Data::Dumper;
  16. use DBI;
  17. use File::Basename;
  18. use File::Spec;
  19. use Getopt::Long;
  20. use Pod::Usage;
  21. use SQL::Abstract;
  22. use Sys::Hostname;
  23. # Handle options, including help generated from the POD above.
  24. my $debug = 0;
  25. GetOptions(
  26. 'debug' => \$debug,
  27. 'help' => sub { pod2usage(0) },
  28. ) or pod2usage(2);
  29. my ($date) = $ARGV[0];
  30. unless (defined $date) {
  31. die "Must specify a date";
  32. }
  33. my $date_for_calendar = $date;
  34. $date_for_calendar =~ s/-//g;
  35. # -t "$date_for_calendar": treat $date_for_calendar as today
  36. # -B 2 -A 0: show last 2 days of entries for context
  37. # -A 14: show next 2 weeks of entries
  38. # -w: show name of weekday
  39. # TODO: Figure out how to get this without the redundancy:
  40. # my $before_today_output = `cd ~/notes && calendar -t "$date_for_calendar" -B 2 -A 0 -w`;
  41. # my $after_today_output = `cd ~/notes && calendar -t "$date_for_calendar" -A 14 -w`;
  42. # print "${before_today_output}/********/\n$after_today_output";
  43. my $calendar_output = `cd ~/notes && calendar -t "$date_for_calendar" -A 14 -B 2 -w`;
  44. print $calendar_output;
  45. 1;