Things I've learned about building CLI tools in Python

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • rules_python

    Bazel Python Rules

  • What's SV?

    I honestly don't know why anyone would use that... as in what does Bazel do better than virtually anything else that can provide this functionality. But, I used to be an ops engineer in a big company which wanted everything to be Maven, regardless of whether it does it well or not. So we built and deployed with Maven a lot of weird and unrelated stuff.

    Not impossible, but not anything I'd advise anyone to do on their free time.

    Specifically wrt' the link you posted, if you look here: https://github.com/bazelbuild/rules_python/blob/main/python/... it says that only pure Python wheels are supported, but that's also a lie, they don't support half of the functionality of pure Python wheels.

    So, definitely not worth using, since lots of functionality is simply not there.

  • finstem

    Simple Finnish stem word finder

  • I build little CLI tools in Python non-stop. ChatGPT and some basic knowledge of how the `click` library works has made it almost completely trivial to get the ball rolling for whatever need I have for it, `--help` text included.

    The fact that the barrier for creation is so low means I'm even willing to do them to solve very niche problems in generalizable ways. [1] is common enough that a few people have starred it. [2] is niche enough that other Anki folks haven't used it AFAICT. [3] is likely something I'll never personally need again, even though Azure VM reservations not letting you customize your reminders for when they're about to expire is probably a costly mistake for a great many firms. All generated with this same starting methodology, because what I wanted was just a little too fiddly to want to hack together with my shell toolkit.

    [1]: https://github.com/hiAndrewQuinn/finstem

    [2]: https://github.com/hiAndrewQuinn/table2anki

    [3]: https://github.com/hiAndrewQuinn/AzureReservations2ICS

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • table2anki

    HTML tables to Anki card packages. Does what it says on the tin!

  • I build little CLI tools in Python non-stop. ChatGPT and some basic knowledge of how the `click` library works has made it almost completely trivial to get the ball rolling for whatever need I have for it, `--help` text included.

    The fact that the barrier for creation is so low means I'm even willing to do them to solve very niche problems in generalizable ways. [1] is common enough that a few people have starred it. [2] is niche enough that other Anki folks haven't used it AFAICT. [3] is likely something I'll never personally need again, even though Azure VM reservations not letting you customize your reminders for when they're about to expire is probably a costly mistake for a great many firms. All generated with this same starting methodology, because what I wanted was just a little too fiddly to want to hack together with my shell toolkit.

    [1]: https://github.com/hiAndrewQuinn/finstem

    [2]: https://github.com/hiAndrewQuinn/table2anki

    [3]: https://github.com/hiAndrewQuinn/AzureReservations2ICS

  • AzureReservations2ICS

    Given the CSV of the Azure Reservations website, create an ICS file of reminder events leading up to the expiration.

  • I build little CLI tools in Python non-stop. ChatGPT and some basic knowledge of how the `click` library works has made it almost completely trivial to get the ball rolling for whatever need I have for it, `--help` text included.

    The fact that the barrier for creation is so low means I'm even willing to do them to solve very niche problems in generalizable ways. [1] is common enough that a few people have starred it. [2] is niche enough that other Anki folks haven't used it AFAICT. [3] is likely something I'll never personally need again, even though Azure VM reservations not letting you customize your reminders for when they're about to expire is probably a costly mistake for a great many firms. All generated with this same starting methodology, because what I wanted was just a little too fiddly to want to hack together with my shell toolkit.

    [1]: https://github.com/hiAndrewQuinn/finstem

    [2]: https://github.com/hiAndrewQuinn/table2anki

    [3]: https://github.com/hiAndrewQuinn/AzureReservations2ICS

  • typer

    Typer, build great CLIs. Easy to code. Based on Python type hints.

  • I have been using Typer on every one of my CLI projects which uses Click under the hood. The documentation is fantastic, the CLI app it produces looks great and lets you create things quickly. I high recommend it.

    https://typer.tiangolo.com/

  • docopt

    This project is no longer maintained. Please see https://github.com/jazzband/docopt-ng

  • I've been using docopt to handle CLI arguments for years now.

    http://docopt.org/

  • trogon

    Easily turn your Click CLI into a powerful terminal application

  • The folks at Textualize have taken it one step further with https://github.com/Textualize/trogon

    It's a neat way to make powerful CLIs more accessible to less-technical users.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • poetry-cookiecutter

    🍪 Poetry Cookiecutter is a modern Cookiecutter template for scaffolding Python packages and apps

  • I can't say I can relate at all. If you do things from scratch that might be true, but there is a pretty popular python tool called cookiecutter that allows you to generate the basic skeleton of the app. I usually pick something that contains poetry, click(I guess there is typed now) and some linting choices.

    For fun I just googled a template and tried: https://github.com/radix-ai/poetry-cookiecutter

    And the result is quite good.

  • python_script_cc

    A personal cookiecutter template for simple python3 scripts

  • I've came to the same conclusion as the author some time ago, my cookiecutter template is more opinionated https://github.com/ArcHound/python_script_cc . Best for use-cases when you need to do some automated API calls. Will checkout Typer and Textualize too, thanks HN!

  • Nim

    Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).

  • You better off with using a compiled language.

    If you interested in a language that's compiled, fast, but as easy and pleasant as Python - I'd recommend you take a look at [Nim](https://nim-lang.org).

    And to prove what Nim's capable of - here's a cool repo with 100+ cli apps someone wrote in Nim: [c-blake/bu](https://github.com/c-blake/bu)

  • bu

    B)asic|But-For U)tility Code/Programs (in Nim & Often Unix/POSIX/Linux Context)

  • You better off with using a compiled language.

    If you interested in a language that's compiled, fast, but as easy and pleasant as Python - I'd recommend you take a look at [Nim](https://nim-lang.org).

    And to prove what Nim's capable of - here's a cool repo with 100+ cli apps someone wrote in Nim: [c-blake/bu](https://github.com/c-blake/bu)

  • pkg

    Discontinued Package your Node.js project into an executable

  • The npm package called "pkg" seems to be the standard for packaging NodeJS applications

    https://www.npmjs.com/package/pkg

    Unfortunately you also need to bundle all your code into a single file for it to work, but you can use any bundler (webpack, parcel, etc) you want at least

  • cligen

    Nim library to infer/generate command-line-interfaces / option / argument parsing; Docs at

  • cligen also allows End-CL-users to adjust colorization of --help output like https://github.com/c-blake/cligen/blob/master/screenshots/di... using something like https://github.com/c-blake/cligen/wiki/Dark-BG-Config-File

    Last I knew, the argparse backing most Py CLI solutions did not support such easier (for many) to read help text, but the PyUniverse is too vast to be sure without much related work searching.

  • v-mode

    🌻 An Emacs major mode for the V programming language.

  • Fingers crossed for vlang[0]. It's like golang with better types and more syntactic sugar. Feels like a proper upgrade from Python.

    I really hope they succeed.

    [0]: https://vlang.io/

  • poetry2nix

    Convert poetry projects to nix automagically [maintainer=@adisbladis]

  • How about converting it to Nix derivation?

    https://github.com/nix-community/poetry2nix

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts