Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
For the purpose of this tutorial, we’ll be building a simple CLI to translate between languages. We’ll accept string type arguments, parse them into a sentence, shoot them off to a translation API which will fetch us the translations, and then display the result. The complete code for this can be found on the Github repository. Let’s dive right into it!
Your CLI is complete now! One thing more that you can do is to decorate the output and errors with boxes and colors, we can do that using boxen and chalk.
Although Node.js offers built-in functionality for handling command line arguments, we are going to use an npm package called yargs 🏴☠ which is specifically made for building CLI s. yargs will simplify our process of parsing arguments and help us organize command line flags.
Related posts
- [OC] termTranslate: Get language translations in the terminal, quickly and efficiently.
- spinoff - an easy library for displaying spinners in the terminal
- got - interact with google translate from the terminal
- Using CLI Applications to Increase Efficiency in Work
- I created a simple CLI tool that helps you code FAST!