Member-only story

I recently started a role on a company’s developer experience team. One of the responsibilities that comes along with this is building larger CLI applications.
As I wrote previously, I use the commander
library when writing DevOps scripts for my NodeJS projects. This is great for smaller utilities that only a couple of people will use, but what about if it needs to interact with multiple services and have lots of nested commands?
As it turns out NestJS supports this using the same commander library that I used previously. In this article, I’ll show you how to create a basic CLI using this setup.
Creating the Project
npm i -g @nestjs/cli
nest new my-cli-project
cd my-cli-project
Creating the CLI project is the same as creating an API with NestJS. Simply follow the basic workflow on nestjs website.
Setup nest-commander
The nest-commander
library provides all the code that you'll need to create your commander CLI in the background. Like every other node dependency, the first step is to install the package.
npm i nest-commander