Skip to content

obedyakpa0-dev/ToDo-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

todo-cli

A simple command-line TODO application written in Node.js.

Files

  • index.js: main executable script (uses commander).
  • package.json: project metadata and todo CLI entry in bin.
  • task.json: local JSON file used to persist tasks (created automatically).

Requirements

  • Node.js v12 or newer

Installation

  1. Install dependencies (none required by default, but run to be safe):
npm install
  1. (Optional) Make the todo command available globally on your machine:
npm link

Usage

  • Run directly with Node:
node index.js <command> [args]
  • Or after npm link, use the global todo command:
todo <command> [args]

Commands

  • add <task> — Add a new task. Example:
todo add "Buy milk"
  • list — List all tasks. Example:
todo list
  • complete <id> — Mark task with the given id as completed. Example:
todo complete 2
  • incomplete <id> — Mark task as not completed. Example:
todo incomplete 2
  • delete <id> — Delete the task with the given id. Example:
todo delete 3
  • Aliases: donecomplete, rmdelete are available as shorthand commands.

  • clear — Remove all tasks.

todo clear
  • clear-completed — Remove only completed tasks.
todo clear-completed
  • stat — Show simple statistics (total, completed, incomplete).
todo stat

Persistence

  • Tasks are persisted to task.json in the project folder. Example format:
[
  { "id": 1, "task": "Buy milk", "completed": false },
  { "id": 2, "task": "Write README", "completed": true }
]

Manually creating a tasks.json file (optional)

If you'd like to create the tasks file yourself (for example to pre-populate tasks or ensure the file exists), create a file named tasks.json in the project root with the same JSON structure shown above. Example:

[
  { "id": 1, "task": "Buy milk", "completed": false },
  { "id": 2, "task": "Write README", "completed": true }
]

Note: the CLI creates task.json automatically by default. If you prefer the filename tasks.json, update the code in index.js to point to tasks.json instead of task.json (search for the filename in the source and change it), or rename tasks.json to task.json so the CLI can read it without changes.

Notes

  • IDs are assigned sequentially based on array length when adding; deleting tasks will not reassign existing IDs in the current implementation.
  • If you prefer zero global installs, run the CLI with node index.js from the project directory.

Troubleshooting

  • If todo is not found after npm link, ensure your global npm bin is on PATH, or run:
node index.js <command>

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors