Master any CLI tool with this one weird trick

Read Time:2 Minute, 27 Second

Just like most developers, I live in the terminal, I savor the ability of automation and the boundless things I can do with it.

Before I start, I want to briefly remark on my setup;

My setup 👽

I used to use bash and know the best as my default shell, but I solely switched to zsh because it become the default in macOS, likewise I use ohmyzsh as my framework. It is a pleasant experience and easy to manage the prompt and plugins.

I recently heard about prezto which is a fork of ohmyzsh but haven’t tried it yet (most of the plugins I use are in ohmyzsh) it is more customizable and less bloated than ohmyzsh.

I use iTerm2 as my terminal, it is a great alternative to the default macOS terminal and has a lot of features – customization.

Writing completion spec 📝

Recently I have contributed to Fig
Specifically to their autocomplete feature withfig/autocomplete which is an open-source project that aims to provide auto-completion for CLI tools.

This is a preview of the autocomplete feature in Fig, the tool taplo is what I wrote the completion spec for.

How it works ❓

While it required some brainstorming and a bit of research, it was a smooth experience to contribute to this project, and I learned a lot. First, I followed their documentation on writing a completion spec, which is well written, and learned a lot about the basic CLI terminology (i.e. command, subcommand, option, argument). Corresponding to what tool you choose to write the completion spec for, you need to learn a bit about the tool itself, which is cool because you get to know the tool better.

I tackled the issue missing spec for taplo #1532.

picture-from-issue

Taplo is a CLI tool for working with TOML files, and it includes features like linting, formatting, and validation. I honestly didn’t know much about TOML before I started working on this, but I learned a lot about both the tool and TOML itself.

Some CLI tools have man pages and in such situations like writing completion spec, people usually use them as a source to learn about the tool and its subcommands options, etc. (Usually they have the best reputation for being the most accurate source of information). Though, the tool I chose to write the completion spec, taplo, did not have any manual entry pages. Even better! I found their website and documentation which was really helpful.

Takeaways 💯

Maintainers of withfig/autocomplete are super active and helpful. They constantly add more issues related to writing brand-new completion specs and improving existing ones. Writing completion specs, I think, is one of the best gateways to learning about CLI tools in depth and contributing to open-source. Also, if you are using Fig you can actually use the completion specs you wrote in your terminal!

Source: https://dev.to/batunpc/master-any-cli-tool-with-this-one-weird-trick-4gn2