coBib goes Textualized!
January 13th, 2022 - this is the date of coBib’s last feature release (v3.5.0) as well as the date of the first few commits of this merge request. So what has happened in the 492 days since then?
The short answer: a LOT!
Life in general, has been very busy. But I more or less steadily refactored coBib to integrate it with these two amazing projects by Textualize: rich and textual. This means, coBib now has a shiny new interface in both, its CLI and TUI, and its code has become a lot more maintainable for the future to come!
If you are interested in finding out what this entails, continue reading. If you simply want to see some screenshots, skim through the page as you like.
In any case: be sure to upgrade coBib now, to get v4.0.0 installed on your machine!
The longer answer
It all started when I first heard about textual
- a then new project from the developer of rich
, a “library for rich text and beautiful formatting
in the terminal”1.
I had been keeping an eye on rich
for a while as it would bring some nice benefits to coBib’s CLI, and when textual
got announced, I knew that I
wanted to refactor the archaic ncurses-based TUI of coBib to become more modern and, especially, a much more maintainable codebase!
So even though textual
was still in its infancy, the refactoring began…
Rich integration
I first set out to integrate rich
. In doing so, I revisit the entire design of coBib’s command classes and also added a “porcelain” output mode for
easy parsing.
Without getting too much into the gory details, here are some screenshots to gorge yourself in:
Textual integration
While the rich
integration was done fairly early in the development cycle, integrating textual
took a lot longer, in part also due to it being
alpha software with some features I needed simply not being available yet.
But it has matured a lot over the last year and I am happy to ship a nice new interface with coBib out today!
Here are some screenshots2:
Functionally, the TUI still works almost exactly as before. You might notice a few minor differences, some of which I plan to iron out in upcoming feature releases, but if you find anything missing or not working, please feel free to open an issue.
Other noteworthy changes
Besides this major UI refactoring, I would like to briefly highlight two other noteworthy changes.
Configuration changes
I refactored the configuration implementation as a Python dataclass
3. This makes the code both, more maintainable and significantly easier to
document online.
However, this means if you used to do the following in your configuration file:
1
config["database"]["git"] = True
You will now need to change this to the following:
1
config.database.git = True
Furthermore, as a consequence of the commands refactoring, a lot of the function signatures of the built-in events have changed. So be sure to update those accordingly.
Label disambiguation
coBib used to be able to detect if an entry already existed in your database and would avoid re-adding it as a duplicate. However, this functionality regressed when I added the label disambiguation feature. With v4.0.0, you will now have the option to decide what to do interactively. And to ease your choice, you will be presented with a side-by-side comparison of the existing and to-be-added entry! Take a look at the screenshot below to see what you might expect from this:
-
These screenshots were generated directly with the help of textual:
textual run --screenshot 5 "src/cobib/__main__.py"
↩