At its core, TF Utils is a little command-line tool with a friendly text-based interface (TUI) that helps automate some of the tedious parts of setting up projects. Specifically, it’s designed for fellow apprentices in the Electronics Technician (Elektroniker) program at TFBern.
Honestly, the whole idea started because I was getting really frustrated myself. As an apprentice here, I also enjoy coding, and the constant cycle of copying project templates, carefully renaming everything, trying to keep track of versions, and dealing with inconsistencies across projects felt super inefficient. I thought, “There has to be a better way,” so I decided to build one. My goal was basically to scratch my own itch and hopefully make things a bit easier for others in the program too.
It didn’t start as anything fancy. My first attempt was just a small Python script to make the standard uVision templates we use work nicely with CLion, which is the IDE I prefer. But I quickly realized that just patching templates wasn’t enough. I wanted to handle more tasks, and a single script was going to get messy fast.
That led me to think about a more organized approach. I started building a system where I could define different tasks or “commands” in separate files. The main program would automatically find these commands and show them in a simple console menu. This worked okay for a while, but managing the user interaction in the console got complicated as I added more features.
That’s when I discovered Textual, a Python library for building TUIs. It was a game-changer! Suddenly, I didn’t have to wrestle with printing menus, handling user input, or clearing the screen manually. Textual provided cool features like pop-up modals and even mouse support, letting me focus on the actual logic of the commands.
Adding new commands became much cleaner. For example, you can just create a new Python file (like hello.py
) in the interfaces
folder, write a function, and add a simple @interface
decorator:
# Example: interfaces/hello.py
from textual.containers import Container
from src.lib.interface import interface # My custom decorator
from src.lib.utils import console
@interface("My First Interface") # This makes it show up in the TUI
async def hello_world(container: Container):
"""This is my first interface!"""
await console.print(container, "Hello, World!") # The actual command logic
The main program picks this up automatically, making it really easy for anyone (even me later!) to add new automation tasks without digging through complex UI code.
Pretty soon, though, I ran into a couple of big hurdles that made me realize Python might not have been the perfect choice for this specific tool, despite being great for getting started:
.exe
file for Windows. Using tools like AutoPyToExe felt like black magic, involving specific DLLs and complicated build scripts that often only worked reliably on my own laptop. This also basically locked the tool to Windows.Thinking about how to solve these issues led me to consider rewriting the tool in Go (Golang). Go seemed like a good fit because:
Right now, TF Utils (the Python version) is a working tool with a pretty nice TUI that does what I originally set out to do: automate common project setup tasks. It’s documented, reasonably easy to add new commands to, and myself and a few friends in the program are actually using it regularly, which feels great! The build process is still clunky, but the tool itself is helpful.
You can check out the documentation here, which I put together using MkDocs with the Material theme: https://imgajeed76.github.io/tfUtils/
So, did I meet my goal? I think so. I wanted a structured way to simplify common tasks, and the current tool does that.
Along the way, I definitely learned a lot:
I’m quite proud of how the TUI turned out and the modular system for adding commands. It feels pretty slick to use.
As mentioned, the next big idea is to actually build that V2 in Go. The plan is to tackle those distribution and speed problems head-on, making TF Utils even more useful and easier to share with everyone in the Electronics Technician program.