Member-only story

Learn how to transform your command line interface into a beautiful textual user interface

Kevin Tewouda
9 min readJan 6, 2024

--

Trogon, a Python solution at your rescue

Photo by Zdeněk Macháček on Unsplash

If you follow my articles, you should know that I love writing and using command-line interfaces (CLI). I usually use Click to develop my CLIs. Sometimes, when you learn how to use a new CLI, it may be a bit difficult to discover all the options available for a given command. It could be nice to have a nice visualization of what a command is capable of, and I’m not talking about the man page for those used to Linux/Unix systems. These pages are generally difficult to navigate. I’m talking about a nice textual user interface giving you hints on how to use a command. And this is what we will see in this blog post with Trogon.

It will also be an occasion to:

  • Discover or remember an advanced concept of Click called context.
  • Learn a shiny and relatively new serialization library.

Installation

To install it, you will need Python 3.7 or higher.

$ pip install click trogon

# or with poetry
$ poetry add click trogon

If you don’t know poetry, I have a nice introduction to it here.

It is not necessary to install Click directly because it is a dependency of Trogon. But Trogon may want to support other CLI libraries in the future and it is not sure Click will be installed by default, so I prefer to add it explicitly. 💁🏾‍♂️

Usage

We will create a simple CLI to illustrate the usage of Trogon. Let’s say we want to create a Todo CLI. Here is how we will want to use this CLI

# create a todo
$ todo create --name=foo

# create a todo with…

--

--

Kevin Tewouda
Kevin Tewouda

Written by Kevin Tewouda

Déserteur camerounais résidant désormais en France. Passionné de programmation, sport, de cinéma et mangas. J’écris en français et en anglais dû à mes origines.

No responses yet

Write a response