TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to write a command line application in Node.js

76 pointsby dpmehta02almost 12 years ago

11 comments

jasondenizacalmost 12 years ago
The number one reason to write CLI apps in node is npm. npm gets package management right, preferring local dependencies to global ones - this means no worrying about what version of a library a user has in their global environment.<p>You also get to bring node&#x27;s parallel io-centric patterns to your scripting. Need to download a bunch of files from a remote host, process them, and write them to disk? Go for it.<p>But take it with a grain of salt: it&#x27;s very much a use-what-you-know kind of thing.
评论 #6190268 未加载
评论 #6189381 未加载
评论 #6189611 未加载
qrohlfalmost 12 years ago
Is there a reason to build a command line application in Node.js? It doesn&#x27;t really seem like Node is the right tool for the job...
评论 #6189156 未加载
评论 #6189160 未加载
评论 #6189179 未加载
评论 #6189327 未加载
评论 #6190521 未加载
评论 #6189566 未加载
评论 #6190064 未加载
meandavealmost 12 years ago
This was also recently released. <a href="https://github.com/chjj/blessed" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chjj&#x2F;blessed</a>
clarlealmost 12 years ago
Definitely check out Inquirer.js if you&#x27;re using prompts in a Node CLI application. It&#x27;s the prompt utility used by Yeoman generators:<p><a href="https://github.com/SBoudrias/Inquirer.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;SBoudrias&#x2F;Inquirer.js</a>
olegpalmost 12 years ago
Callbacks and CLI apps aren&#x27;t a good fit in my opinion. I do like writing command line tools using Common Node though: <a href="https://github.com/olegp/common-node" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;olegp&#x2F;common-node</a>
lognalmost 12 years ago
Or you could just use <a href="http://silkjs.net" rel="nofollow">http:&#x2F;&#x2F;silkjs.net</a>
petercooperalmost 12 years ago
Something similar but published just last week: <a href="http://flippinawesome.org/2013/07/29/writing-a-command-line-utility-using-node/" rel="nofollow">http:&#x2F;&#x2F;flippinawesome.org&#x2F;2013&#x2F;07&#x2F;29&#x2F;writing-a-command-line-...</a>
rtsukalmost 12 years ago
I find the lack of a synchronous way to pass a command to the shell and get the result makes node much more difficult for the kinds of things I usual write in ruby.
oscargrouchalmost 12 years ago
in this day and age, if i had to create a command line app, from zero, i would definetly start with go.. it has all the functionality in standard libs and the package manager can handle github repos for third-parties (like mongo or mysql drivers).. you just compile it and go!<p>can be as simple than that? the right tool for the job..<p>if i would create a library that everyone could use and embed i would use C for that..<p>if i would like to build a VM, a compiler, a browser or a OS i would use c++ (is almost c, fast and gives you easy composability and control)<p>i would use javascript.. but only in the browser and because and dont have nowhere to go or to runaway for.. (no transpiling either please)<p>this is just the general experience of my years of coding and deling with every lang in the earth.. rsrs<p>ruby is pretty, eyecandy, bu is like a virgen that cant be touched.. python looks just like perl.. is a complete mess, and is like the mafia,i prefer not to touch or to have any involvement with them.. java is the frankenstein child of c++.. you can create big software with it.. but to many keywords and excessive use of vtables..<p>and for ui and web, network, etc.. i would use something like dart for this job, any day.. the code can grow and you can still understand your code<p>so these days i would use c, c++, go or dart.. in the case i can choose of course.. :)
评论 #6190173 未加载
评论 #6190195 未加载
vehementialmost 12 years ago
Bunch of broken URLs due to closing parentheses
dpwebalmost 12 years ago
github.com&#x2F;dpweb&#x2F;cli-node