Boiler plate code? Enter cht.sh command line!

1 minute read

With this command line tool we can find boilerplate code snippets significantly faster at no cost. Find out how in the following geeky coffee break.

What

In this geeky coffee break we reveal the cht.sh command line tool. This command line tool can automate a good deal of a programmer’s work as it is a real cheat sheet for programmers. We can leverage cht.sh to find code snippets and boilerplate code in 56 different languages (Python, shell, Go, Lua, etc.) using text descriptions.

Why

Boilerplate code is boring, we don’t dedicate attention and tend to forget it immediately. Yet, we need the boilerplate snippets over and over in different projects, iPy Notebooks and so on. In order to automate their retrieval we can use tools such as cht.sh.

How

After the successful installation of the cht.sh we can immediately start using it. We will demonstrate how to use for searching Python code snippets.

First we have to start the client by running the following command:

$ cht.sh --shell python


Then we start writing queries using natural language. For example we can type load a json file which will result in finding the following snippet:

1
2
3
4
import json
with open('strings.json') as f:
    d = json.load(f)
    print(d)


Pretty cool, huh? Below is an illustration on running cht.sh for different queries.

Animation showing the use of the cht.sh command line
Illustration: How to use cht.sh for Python to find boilerplate code


If you liked this post you can subscribe to the mailing list below to get similar updates from time to time.

Leave a comment