DEV Community

Cover image for How to make beautiful, simple CLI apps with Node

How to make beautiful, simple CLI apps with Node

Hugo Di Francesco on June 20, 2018

Channel your inner Sindre Sohrus and ship a beautifully simple CLI app using Node. Command line apps are a neat way to package repetitive tasks. T...
Collapse
 
jvarness profile image
Jake Varness

I too have used commander on projects and I really enjoy using it!

Another pattern that you could follow instead of using index.js as the entry point for your program is to have the actual executable in a bin folder in your package. That way, you can separate your actual package from how it gets executed. Following this pattern, module could be used as a CLI or consumed as a library rather than purely being a CLI.

Collapse
 
hugo__df profile image
Hugo Di Francesco

Yeah that was done for the sake of simplicity in a blog post, less files and folders is better to just quickly walk through some awesome packages.

Collapse
 
namirsab profile image
Namir

I've used commander and it was a pleasure to use. I like the listr package :D

Collapse
 
zalithka profile image
Andre Greeff

Listr is seriously cool, thanks for the introduction.. I've written a whole bunch of quick-fix Windows batch and *nix bash files over the years, which I've been meaning to port over to Node scripts for ages now.

This post just gave me the inspiration to get started on that task. Maybe I'll even make a cool little menu system for the scripts in my folder too.. Hehe. :D

Collapse
 
hugo__df profile image
Hugo Di Francesco

Glad it helped 😊 shame I haven't done much cross platform shell stuff 🤔

Collapse
 
caseywebb profile image
Casey Webb

It should be noted that shebangs will not work on Windows, so for documentation it is still a good idea to use node index.js.

Collapse
 
zalithka profile image
Andre Greeff

I can't use the OS I really want to at work, so I end up running Hyper Terminal with Git's bash.exe as my shell..

There are many other advantages of this route (like autocomplete on environment variable names), but in this particular case it means you can technically use shebangs "in Windows". (: