Command line interface Icon

Command line interface

A CLI, or command-line interface, is a console that helps users issue commands to a program.
126 Stories
All Topics

Martin Heinz martinheinz.dev

Make your CLI demos a breeze with zero stress and zero mistakes

Running live demos can be stressful. You know what you want to say and show. You prepare the CLI commands you want to run to best showcase what you’ve built, but then you waste time typing long commands; you make typos; the commands fail or take way too long to complete. Maybe they depend on external system (network, APIs, cloud, …) and of course it’s not cooperating while you’re running your live demo.

Here’s how you can avoid all of the above by scripting, automating and recording your demos, so that you never have to stress about showcasing ever again…

Command line interface daniel.haxx.se

trurl manipulates URLs

Daniel Stenberg’s new tool for parsing & manipulating URLs might fit nicely into HTTP your utility belt.

URLs are tricky to parse and there are numerous security problems in software because of this. trurl wants to help soften this problem by taking away the need for script and command line authors everywhere to re-invent the wheel over and over.

Nix github.com

Instant, easy, predictable shells and containers

If Nix seems too daunting, this might just be a great way to reap one of its benefits without getting lost in its complexity.

Devbox is a command-line tool that lets you easily create isolated shells and containers. You start by defining the list of packages required by your development environment, and devbox uses that definition to create an isolated environment just for your application.

Command line interface lifehacker.com

I raised my kids on the command line... and they love it

John Goerzen built a computer for his 3yo, installed Debian on it, and set up a GUI for it.

The looks of shock I get from people when I explain, as if it’s perfectly natural, that my child has been able to log in by himself to a Linux shell since age 3, are amusing and astounding. Especially considering that it is really not that hard.

It’s not that hard, but it is so foreign to people that they’re quickly impressed by such things. Still, John decided to introduce his kids to a GUI eventually:

Jacob mastered the basics of xmonad really quickly. Alt-Shift-C to close a window. Alt-Shift-Q to quit back to the “big black screen”. Alt-Shift-Enter to get a terminal window.

We launched thunar (the XFCE file manager) and plugged in his camera. He had a good deal of fun looking at photos and videos from it. But then I dropped the true highlight of the day for him: I offered to install Tuxpaint for him. That’s probably his favorite program of all time.

Tux Paint!

JSON github.com

An interactive wrapper around `jq`

Nick Nisi shared this with me recently and it’s cool, so I thought I’d pass it along. Here’s Nick describing it:

And it is a visual wrapper around jq, that kind of does the fzf type thing where as you’re writing out your query, it’s live showing you a preview in virtual text of exactly what would get returned by what you’re querying as you go. So you can use that as a nice tool to build out your jq syntax, or your jq query, and in real time get that feedback.

The only bummer is that it’s written in Ruby. Don’t get me wrong, I love Ruby. But it requires you to have Ruby tooling on your machine to use jqq, which many people don’t have or want. BUT it’s a mere 241 lines of code, so porting it to something a little more portable shouldn’t be too much work…

Command line interface github.com

AirDrop files directly from your CLI with OpenDrop

OpenDrop is a command-line tool that allows sharing files between devices directly over Wi-Fi. Its unique feature is that it is protocol-compatible with Apple AirDrop which allows to share files with Apple devices running iOS and macOS.

Super cool, but with a disclaimer: this is the result of reverse engineering the transfer protocol, so the odds of it being flakey (especially as Apple ships OS updates) are high. It’d be rad if Apple would publish an AirDrop-compatible specification for the community to rally around.

You know, like they did with FaceTime. 😉

Command line interface hurl.dev

A CLI that runs HTTP requests defined in a simple plain text format

There are a lot of HTTP client tools out there. This one is neat because of its simple/repeatable plain text API that I’d imagine works great for writing integration tests.

# Get home:
GET https://example.net

HTTP/1.1 200
[Captures]
csrf_token: xpath "string(//meta[@name='_csrf_token']/@content)"

# Do login!
POST https://example.net/login?user=toto&password=1234
X-CSRF-TOKEN: {{csrf_token}}

HTTP/1.1 302

Kubernetes github.com

Datree is a CLI to ensure K8s manifests and Helm charts follow best practices

Datree is a CLI tool that supports Kubernetes admins in their roles, by preventing developers from making errors in Kubernetes configurations that can cause clusters to fail in production. Our CLI tool is open source, enabling it to be supported by the Kubernetes community.

It’s far more effective than manual processes, such as sending an email to a slew of developers, begging them to set various limits, which likely falls on deaf ears because developers are already overwhelmed.

In addition the CIL, Datree provides a web app interface which you can see in action right here.

Go github.com

A highly customizable and lightweight framework for crafting Go CLIs

Nice is a highly customizable and lightweight framework for crafting CLI apps.

Nice respects idiomatic Go code and focuses to be clear, efficient and easy to write and maintain.

You can use it as a full-featured non-opinionated framework or use any nice packages as stand-alone libraries.

I’m a big fan of the similar projects section in the README. Classy!

A highly customizable and lightweight framework for crafting Go CLIs

JSON earthly.dev

Getting to know JQ

This is a solid primer on the usefulness of jq (a lightweight, command-line JSON processor.)

In this article, I’m going to go over the basics building blocks of jq in enough depth that you will be able to understand how jq works. Of course, you still might occasionally need to head to google to find a function name or check your syntax, but at least you’ll have a firm grounding in the basics.

Command line interface github.com

Bashly - Bash CLI Framework and Generator

This comment on HN does a great job summarizing Bashly.

…think of this as an argparse equivalent for Bash. You provide a YAML file listing commands, subcommands, arguments, and flags, and it automatically generates a Bash script that can parse and validate them, provide help messages, and run your code for each command.

It also lets you keep the actual code for each command and subcommand in separate files, which are merged together into one distributable Bash script at generation time. It’s basically a templating system to auto-generate argument parsing so you don’t have to solve that again or deal with things like optparse.

Brett Cannon snarky.ca

Introducing the Python launcher for Unix

Brett Cannon:

… over 3 years ago I set out to re-implement the Python Launcher for Unix in Rust. On July 24, 2021, I launched 1.0.0 of the Python Launcher for Unix… This gives you a py command on Unix which will always use the newest version of Python.

He goes on to describe some workflow niceties that a built in and also what this project is not about:

The Launcher is purely a convenience and not meant to be The Launcher For All Things; this should never end up in a Docker container.

Nick Janetakis nickjanetakis.com

Using `envsubst` to merge environment variables into config files

Nick told us about this on our modern Unix tooling episode, but I thought I’d link up his excellent writeup/video on the subject for those who had a hard time following with audio only.

Let’s say you have an nginx or Kubernetes config file which doesn’t support templating out of the box and you want to dynamically create config files based on 1 or more environment variables. This is what envsubst lets you do.

Player art
  0:00 / 0:00