clk

A very opinionated framework to ease the creation of command line interfaces

View on GitHub

clk

Technical Debt

Vulnerabilities Bugs Code Smells

Lines of Code Duplicated Lines (%) Coverage

Maintainability Rating Reliability Rating Security Rating

Quality Gate Status CircleCI

Gitter Libera

Come and discuss clk with us on

clk, the Command Line Kit is a unique tool that aims to contains everything needed to create human friendly command line tools.

The rationale attempts to explain why clk started to exist. You will find in the use cases classical situations where clk is worth being used. In the future, we might write even more documentation.

Use cases

This is most likely the most useful part of the documentation. Take a look at the use cases to find out how clk could be used in real life situations.

In a nutshell

Install with

curl -sSL https://clk-project.org/install.sh | bash

Then create a hello world command with

clk command create bash hello-world --description "Some simple hello world command" --body 'echo "Hello world"'
clk hello-world
Hello world

This actually does not tell you much why clk is so awesome. Try taking a look, the use cases to get more real life examples.

Rationale

Low level command line tools are very powerful. Yet they are not very intuitive. It takes time to understand those like find, kill, tr, awk or sed. We spend a lot of time reading the documentation and the tool itself does not help much1.

It looks like a lot of high level command line tools, like maven or npm have followed the same idea of relying on a comprehensive documentation and do not provide a friendly user experience.

Yet, there are a lot a stuffs that the command line tool itself can do to become less a burden and more a partner.

One awesome command line tool on that matter is git. There are semantic completion for almost everything (git push <tab> shows the remotes and git push origin <tab> shows the branches). You can create aliases to shorten commands you often use. Almost every behavior can be enabled or disabled using config. Most commands provide meaningful suggestions of what commands you are likely to want to call next.

The concepts behind git are not that easy and a good and comprehensive documentation is still needed. But git tries its best to be as friendly as possible anyway.

I think that tools like git opened my mind and made me realize that command line tools are not necessarily obtuse.

The Command Line Kit was started in 2016 out of the frustration of dealing with yet another set of command line tools that provided only the bare minimum that a CLI can provide.

In my mind, the authors of those tools did not willingly create obtuse tools. They most likely could not afford the cognitive load of having to thing about such “non functional” feature.

For that reason, clk provides out of the box a nice completion framework, aliases and a way to save configuration, so that when writing my command line tools, I don’t have to think about them. They are automatically there2.

There already exist awesome libraries to create nice command line interfaces. click provides an easy way to write the commands, tqdm provides nice progress bars, humanize helps converting dates and intervals to human readable ones. What clk does is use all that and opinionatedly combines them to create a “batteries included” tool.

Nowadays, I use clk for most of my day to day use, from communicating in slack to fetching rss, to getting my mails or to play music. Under the hood, I use the classical tools such as flexget, offlineimap or mopidy. They simply are wrapped in a very user friendly overlay.

Note on version

clk is quite old, and most of its concepts are stable. There are still a few areas that I want to dig into before starting a v1. For a start, I want to end up describing all the use cases that matter to me before considering it ready.

Footnotes

1 After more than a decade of use, I still have a hard time finding out how to use find for non trivial use cases.

2 for that reason, clk is also called the *C*ognitive *L*oad *K*iller.