clk

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

View on GitHub

Here are some use cases that hopefully will have the following properties:

bash commands

The basics are covered here. To get more into how to provide parameters to your command, read that one. If your parameters are too complicated to be simply parsed, follow the idea of this use case.

If you find out that your bash command starts to become quite big, read this to find out how to split your code.

Most of my bash commands start with simple aliases. You can read more about this way of thinking in here.

parameters, alias etc

Sometimes, you might want to have some control about how the arguments of the command lines are evaluated, take a look at this use case to know more about them.

how to structure your commands

To create powerful, dynamic command line tools that provide the best completion possible, see this pattern for writing your commands. In case you have some issues, you might want to look at the advanced use cases.

commands as first order objects

Sometimes, you create commands not only to be called directly, but to be used as basis to build greater commands.

This example of an ethereum local environment dev tool shows how to plug clk commands as parameters in other commands.

ipfs name publish shows how to use clk bash commands to create the completion for other commands.

batteries included

Like python, clk try hard to provide most of the things you want in a generic command line tool.

In shell command, the library included by default (called _clk.sh) provides some useful helpers to help you create a nice and friendly command, despite, well… bash.

When you want to provide some choices in command, it might be worthwhile to look at those examples.

To cache some computation to disk, see the web scrapping use case.

We put a lot of useful logic in clk.lib but did not document much as of now. This is the current state of this documentation.

Some commands might need to use secret, here is how we implement that.

project

Sometimes, you want to gather some commands or configuration in a folder. We call that folder a project.

If you want to do that to, you might want to read this.

flow

When your commands need to be connected and called in a sequence, we call that a flow.

clk does not want to compete with flow tools, like nodered, but it helps having a basic flow handling from time to time, like when you have a 3D printing flow.

is it a tool or a library?

If you don’t want to use the clk command line tool, you can roll your own.