"i have done a couple bad things"


number of years i have lived on this earth
over 30

🫧 Gum
shell · Command-line input and styling utilities

Bills itself as "a tool for glamorous shell scripts." This is not a library for a particular language -- gum is a command-line utility that is basically a collection of user input widgets, which is very useful and neat for writing shell scripts! There are short- and long-form text inputs, interactive pickers and filters, and utilities for styling the colors and layout of how this is displayed in your shell.

I was originally using gum in a shell script, but when I switched over to writing a Python script, I liked it so much that I plopped it right in as a subprocess.

🔥 Fire
Python · Turn any Python object into a command-line utility

This one is so handy that I feel like probably """everyone"""" already knows about it and I just missed a memo. This one is from some engineers at Google with the caveat that it is "not an official Google product", lol. ANYWAY, here is the entirety of the helper script I made for interfacing with ytmusicapi:

#!/usr/bin/env python3

import fire
import json

from ytmusicapi import YTMusic

if __name__ == '__main__':
    fire.Fire(YTMusic, serialize=json.dumps)

That's it! That's the entire thing!!! My one protip is including serialize=json.dumps in the constructor, because Fire will want to pretty-print your dictionary, and then if you're like me, you'll try to pipe it to jq and get parse errors and be really confused about what you're doing wrong until you realize It Was The Input All Along. Oops.

⌨️ Typer
Python · A library for building CLIs with great developer ergonomics

Another one that anybody who's been writing CLIs in Python already knows about. It's built on top of Click with even more niceties added, like pretty formatted help and generated shell completions (this one really makes me feel like I'm living in 2023! wow!).

Also, shoutout to Rich, which I didn't know about before Typer, but handles all the "make it pretty" stuff in there. The only thing I've done with it so far is make a progress spinner, but I'm excited to mess with the panels and live display so I can replace a really clunky external dependency I have on fzf in one of my scripts!!! It just looks so much nicer to deal with than curses or blessings 😮‍💨. (If these words mean nothing to you... sorry.)

Okay that's all for my roundup for now!!! Cool!!!


You must log in to comment.