When it comes to excellent command-line tools, one stands out in my mind: Git. The Git CLI uses modes, then flags, sometimes with arguments, and then the command argument. This structure is flexible, friendly to use, and pleasant to work with. It is, however, not trivial to implement in a generalized way, especially if we want it to be strongly typed.

I have implemented a small but sophisticated library for parsing command-line arguments in the Git style. In this post, I detail how to use it and its key features. If you want to look at the source code behind it all, you can check it out over at my GitHub:  https://github.com/thedrlambda/typed-cmdargs.

Let’s examine how the library works by showing how we would implement a small CLI tool for managing repositories on GitHub from the command line.

#typescript #architecture #cli #nodejs

CLI Architecture in NodeJS
4.85 GEEK