gohyiqian / task-cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Task Manager Command Line Tool

Reference

  • commander: This helps us to build the CLI tool.
  • chalk: This makes messages in the terminal colorful and easy to read.
  • inquirer: This lets us ask the user for input.
  • ora: This makes the terminal show nice spinning animations.

Set up

# create package.json
npm init --yes
# install dependencies
npm i commander inquirer chalk ora mongoose nanoid dotenv

Update Package.json

# remove
"main": "index.js"
# add
"exports": "./index.js",
 "type": "module",

Test the db

node ./db/connectDB.js
node ./commands/addTask.js
node ./commands/deleteTask.js
node ./commands/readTask.js
node ./commands/updateTask.js

Save the CLI tool

Add bin property. The "bin" property in the package.json file enables you to specify commands that become globally accessible once your package is installed.

"bin": {
  "todo": "index.js"
}

You can start using the tool by installing it globally

npm i -g .

Here are commands you can use to operate the tool

# Create a new task
todo add
# Read all your pending tasks
todo read
# Update a specific task
todo update
# Delete a task
todo delete

# check version
todo --version
todo -V
# display help for commands
todo --help
todo -h

About


Languages

Language:JavaScript 100.0%