Skip to content

A simple CLI tool that translates sentences into different languages directly from your terminal, using Google Translate API. Built with Node.js

Notifications You must be signed in to change notification settings

chhaviluthra08/my-cli-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Creating my own cli from sratch

Refered to the documentation Lets-build-a-cli-with-node-js which made it atleast 10 times easier to understand how I can build my own cli from scratch, this is a fairly simple one where the entered string gets translated to a language that has been mentioned in the command line besied the option provided(-l in this case). As someone who is exploring git, github and bash commands as well, this was a small project that honestly felt extremely fun to work on though it did take some tries to make it work. If youre using the latest versions of yark, chalk etc etc the above documentation's code might need some tweaks (mine did).

Libraries used :

  1. Chalk : Adds colors and styles to the console output. chalk-package
  2. Yargs : Helps in building the command line interface. yargs-package
  3. Google Translate API : Allows your CLI to translate text directly in the terminal. google-translate-reference
  4. Figlet : Adds loading spinners while performing async tasks (e.g., fetching data). figlet-package
  5. Boxen : Draws boxes around text in the terminal. boxen-package

To make it work on your system

  1. Fork this repository on GitHub.

  2. Clone your fork to your local machine:

    git clone <your-fork-url>
    cd <repo-name>
  3. Install the required dependencies:

    npm install
  4. Link the CLI globally so you can use it anywhere:

    npm install -g

    This will register your CLI command system-wide.

  5. Run the CLI:

    <cli-command>

    This will guide you on how to translate text or check the CLI version.


⚠ If you face errors

1. EEXIST: file already exists

This means a previous version of the CLI is already linked. To fix:

npm uninstall -g <cli-command>
npm link

Or force overwrite:

npm link --force

2. Cannot find module '<module-name>'

This happens when dependencies are missing. To fix:

npm install

3. CLI not found after installation

Make sure your global npm bin directory is in your system PATH. On macOS/Linux:

echo $PATH

On Windows:

echo $env:PATH

About

A simple CLI tool that translates sentences into different languages directly from your terminal, using Google Translate API. Built with Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published