home ¦ Archives ¦ Atom ¦ RSS

Bootstrapping Python CLI Packages

As an avowed command line interface (CLI) guy my default approach to building new Python functionality is to write a packages that’s embedded within a CLI right from the getgo. Fortunately, Python is blessed with many packages to support this. click and typer are my gotos. I so admire click that I believe the package should be a part of the Python standard library.

I also have a few opinions regarding packaging (uv please), logging (use loguru), and configuration (platform user directories + TOML files). If you do enough of these CLIs within a certain period of time, you start to yearn for some bootstrapping automation. Recently I landed on a couple of packages that align with my preferences and could really help here.

First off is a batteries included cookiecutter for new Python packages.

There are many cookiecutter templates, but this one is mine and I’m sharing it with you. Create complete Python packages with zero configuration - including CLI, testing, documentation, and automated PyPI publishing via GitHub Actions.

Second is the typerdrive package (background from Tucker Beck)

During my time as an engineer working primarily with Python, I’ve written a a fair number of CLIs powered by Typer. One type of project that has been popping up for me a lot lately involves writing CLI programs that interface with RESTful APIs. These are pretty common these days with so many service companies offering fully operational battlestations…I mean, platforms that can be accessed via API.

I’ve established some pretty useful and re-usable patterns in building these kinds of apps, and I keep finding new ways to improve both the developer experience and the user experience. Every time I go about porting some feature across to a new or old CLI, I wish there was a library that wrapped them all up in a nice package. Now, there is typerdrive:

These are the challenges I found myself facing repeatedly when building CLIs that talk to APIs:

  • Settings management: so you’re not providing the same values as arguments over and over
  • Cache management: to store auth tokens you use to access a secure API
  • Handling errors: repackaging ugly errors and stack traces into nice user output
  • Client management: serializing data into and out of your requests
  • Logging management: storing and reviewing logs to diagnose errors

typerdrive wraps all this up into an interface that’s easy for users and developers as well.

I could see myself creating a combination of these two into a new cookiecutter with a few tweaks of my own for AI engineered CLIs and REPLs. My thanks to the fine gentlemen who authored these packages and made them publicly available.

© 2008-2025 C. Ross Jam. Built using Pelican. Theme based upon Giulio Fidente’s original svbhack, and slightly modified by crossjam.