Some of you might know my little project rate. It is a bash script to collect a database of things you want to rate.
What this means and why I started to reimplement in C++ - read it here!
So I started to write this application because I wanted to keep track of animes I already watched, Bands I like but do not listen to that often and so on and so forth. What the application does is really simple: You can enter notes about a certain thing (in your favourite text editor, which is vim for me) and attach tags to it and put it into a category. Then you can give it a rating. The rating can be everything, from simply numbers to text to whatever you like. But it is supposed to be a number between 1 and 10, of course. That’s also the way I use it.
So how does it work? Well, that’s really simple: The “rate” script creates a
directory structure in
~/.rate/collections/, whereas a folder is a
“collection” of things and a file is a rating. So, I have something like
“movies/animes/” as collections (they are nested, of course) and then a file
for each anime I watched. The filename is generated from the title I passed
“rate” when creating the entry. The file also contains a “header”, which
includes a unique ID (which you really should not change), a list of tags, the
title (the filename is the title, too, but as on linux you shouldn’t include
whitespace in file names, it is not the title as you typed it) and a rating of
course. Custom fields could be added to the header, but this feature is not
implemented yet. After the header, you can put your description.
That’s basically it. “rate” provides some features to search this database,
for example you can
grep for text in your entries, you can view your
entries, you can list your entries and you can attach more text to your
entries or edit them. As everything is git controlled in the
directory, you can reset if you (or the script,…) messed up somehow.
There’s no release by now, as it lacks of some features by now. For example I
want to be able to search for entries with a certain rating or within a
certain range of ratings. I also want to be able to search for entries with aspecial set of tags or within a certain collection (I can do this, though)
special set of tags or within a certain collection (I can do this, already)!
After these things are implemented, I will release my first version, which
1.0 then. And, of course, I will package it for NixOS!
So why C++
Well, I have to learn C++ for my praxis semester. That’s basically it. I
wanted to learn a new programming language for a relatively long time, and
that’s my approach on learning C++. I was able to implement some things, but
not yet to run an application. My first step would be to parse my already
existing entries. Hope that works. As I stated in the github repos
file, I do not want to use any frameworks for this. No Boost, no Qt, no other
libraries. I just want to use plain C++11 (or maybe 14 in future, not sure
about this, though).
Also, C++ gives me way more posibilities when it comes to features. I can refactor things really easy and maybe the C++ implementation will continue to live whereas the bash implementation will die at some point. Who knows? The point is, the bash implementation implements a file format which is
- really simple
- forward compatible
The file actually looks like this:
key = value other = value another = another --- <text>
and that’s basically it. The three dashes mark the end of the header and
everything before the header is a
<key> = <value> list, whereas each line is
only allowed to contain one key-value-pair. The value can be a list of values,
for example a list of Tags whereas tags are seperated by a whitespace
character (space) or a string, such as the title is. The bash implementation
“knows” which key has to be which value and the C++ implementation has to know
this, too, of course. But that’s it.
The commandline interface of the application needs some work, though. Maybe it will get some REPL-like interface later on, or maybe something more interactive. By now, it is simply an interface where you can do one thing per call. I have no problem with that and I’m planning to keep backward compatibility with the bash implementation even if this one is not even released! It is fun to write such a tool and I really like doing it.
Also, it is not a that complex thing to implement and that’s a huge point to me. I don’t want to spend months and months in implementing a thing which only one or two people on this planet actually use. For bigger projects, I contribute to open source projects. That’s a better way to produce large-scale software, IMHO.