Master any CLI tool with this one weird trick
Tags: opensource, programming, tutorial
Published: 2022-12-15 06:56:25


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](https://github.com/ohmyzsh/ohmyzsh) as my framework. It is a pleasant experience and easy to manage the prompt and plugins. 

> I recently heard about [prezto](https://github.com/sorin-ionescu/prezto) which is a fork of ohmyzsh but haven't tried it yet (most of the [plugins](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) I use are in ohmyzsh) it is more customizable and less bloated than ohmyzsh. 

I use [iTerm2](https://iterm2.com) as my terminal, it is a great alternative to the default macOS terminal and has a lot of [features - customization](https://iterm2.com/features.html).

### Writing completion spec 📝

Recently I have contributed to [Fig](https://fig.io/?ref=github_autocomplete)
Specifically to their autocomplete feature [withfig/autocomplete](https://github.com/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](https://taplo.tamasfe.dev/) is what I wrote the completion spec for.


![picture-from-terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yccckfzbu46d9xwaatco.png)



### 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](https://fig.io/docs/getting-started/first-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](https://github.com/withfig/autocomplete/issues/1532).


![picture-from-issue](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2puk5kz5y2y5s6phqhrj.png)



 Taplo is a CLI tool for working with [TOML](https://toml.io/en/) 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](https://taplo.tamasfe.dev/) which was really helpful. 

### Takeaways 💯

Maintainers of [withfig/autocomplete](https://github.com/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](https://fig.io/?ref=github_autocomplete) you can actually use the completion specs you wrote in your terminal!