Tracking tags across a project with todoget
It was 2021 and I was abroad for my PhD. Was a very hot summer (as usual) in Israel and I was working on an experiment for my thesis. The lab where I was working used to use a very complicate but powerful software for running experiment called Presentation. I used to work with R and a little bit of python and Presentation was very unintuitive. A strongly typed language, little documentation, C-like syntax and so on.
Anyway, while programming the experiment I realized that I was working on a folder with multiple other files and scripts and in each file there was multiple lines of code that required refactoring, clarification or further improvements. Was not easy to track all these TODO tasks. In the meantime, I was aware of the todor
that basically was able to scan all files in a folder and create a report with all lines of code with a certain pattern (e.g., TODO, FIXME). Great package but I needed something:
- more general and flexible (like a bash or command line script)
- not only for the R world
- easy to install even in a temporary machine (like when you are abroad in another lab)
At the same time, I really wanted to learn something new, especially related to python. So it was a fantastic opportunity to develope something in python that also solve a very practical problem. I was always aware about the fact that when you want to learn something related to programming, the best option is to solve a problem or develop a project instead of reading books or tutorials. While developing the tool, I learned about classes, methods, OOP, Python packages, CLI tools and so on. It was a really important and fun experience that drastically improved my python knowledge.
The tool is called todoget
and can be found on Github github.com/filippogambarota/todoget. The tool can be installed (if you have Python
and pip
) with:
pip install git+https://github.com/filippogambarota/todoget.git
The package is still in beta and for Python experts please do not judge me. I am pretty sure that it do not follows python and coding best practices. But it works, and for me is enough. Maybe in the future I will refactor the code adding some new functionalities. Before showing how it works, why do not using the add-ons of common text editors? For example, VScode has the amazing Todo Tree
plugin that interactively shows you the location of all the tracked tags. This is amazing but is VScode-specific.
I wanted something more general that can be used in the terminal and most importantly, easily integrated in scripts. For example, you are working on a R project with multiple files and you have some scripts with a README for running the entire project. You can easily integrate todoget
in your workflow and create a report in the README with all tracked tags.
todoget
has 3 commands, init
, scan
and open
:
init
as the name suggest is used only once. It creates the.todoget
configuration file that can be used to exclude/include folders and files (a.gitignore
like functionality) and add more tags to track (default is only TODO)scan
can be used to scan all files and create a.md
report with the files and lines where a certain patter was found.open
basically convert the.md
file into.html
and open the report on the browser.
Something that I would like to improve in the future is:
- refactoring and improving the OOP part
- implementing the ability to have an hyperlink to the file and the specific line. While the way of opening the file protocol is common across editors and OS, opening the specific line is more difficult. Probably requires some hard coding related to the specific text editor