For some time now I wanted to learn Rust, but I either didn’t have the time or couldn’t come up with a nice beginner project. Given that I recently found myself to be without a job and we had another lockdown in the part of the world I happen to live in, I decided to give that idea another go (no pun intended).
There is apparently a trend to reimplement existing Unix tools in Rust (see
exa, a ‘modern replacement for ls’,
delta, a syntax highlighting pager for
git, diff and grep output, bat, a ‘cat clone
with wings’, zellij, a terminal workspace,
ripgrep, a line-oriented search tool
…). I looked around what else was out there, but what I wasn’t able to find
was an implementation of cal(1) in Rust (maybe I wasn’t looking hard enough,
feel free to point anything out to me I might have overlooked).
No cal in Rust even though a calendar implementation would provide the
potential to go over the top with terminal colors, which is also very important
when writing reimplementations of older CLI tools! So I started writing and
soon had a simple prototype of a cal reimplementation. A couple of weeks
later I can now present carl, a cal
implementation in Rust:

The default output of carl is what you would expect from a commandline
calendar tool. It prints the days of the current month and highlights the
current day. Other than the cal tools I tried, carl by default also prints
days that are in the past in grey. Like cal it can also print three month if
you use the -3 switch or the whole year if you use the -y switch.
Colors
You can use a theme file to change the colors carl uses for various
dates. The name of the theme is set in carls configuration file (in
XDG_CONFIG_HOME/.carl/config.toml or system-wide in
XDG_CONFIG_DIRS/.carl/config.toml) using the theme setting - carl looks for
the theme in the file ${themename}.theme in the configuration folders. A
custom theme could for example look like this:

You can change the foreground color, background color and/or style of a date
using a combination of various stylenames like BGRed, Bold and FGCyan.
The README lists
all possible stylenames. A list of date properties defines which dates the
specific style should affect- date properties are for example CurrentDate,
AfterCurrentDate or FirstDayOfMonth. Again, the
README lists the
existing date properties and I’m happy to implement more of them, if you have
ideas.
Ical support
I also added the option to list .ical files in the configuration file. carl
can display the dates from the ical file(s) with a separate style. There can
either be a global style for all the dates from all the ical files by using the
IsEvent date property or a separate style for the dates of a specific
*.ical file.

Using the --agenda commandline switch carl also shows an agenda of dates
from the ical files.
Installation
I have uploaded carl to crates.io, so you can
install carl using cargo: cargo install carl. I also plan to upload it to
Debian at some point. If you find bugs or have feature requests, please don’t
hesitate to create issues.
rust calendar debian