A simple command-line TODO application written in Node.js.
Files
- index.js: main executable script (uses
commander). - package.json: project metadata and
todoCLI entry inbin. - task.json: local JSON file used to persist tasks (created automatically).
Requirements
- Node.js v12 or newer
Installation
- Install dependencies (none required by default, but run to be safe):
npm install- (Optional) Make the
todocommand available globally on your machine:
npm linkUsage
- Run directly with Node:
node index.js <command> [args]- Or after
npm link, use the globaltodocommand:
todo <command> [args]Commands
add <task>— Add a new task. Example:
todo add "Buy milk"list— List all tasks. Example:
todo listcomplete <id>— Mark task with the given id as completed. Example:
todo complete 2incomplete <id>— Mark task as not completed. Example:
todo incomplete 2delete <id>— Delete the task with the given id. Example:
todo delete 3-
Aliases:
done→complete,rm→deleteare available as shorthand commands. -
clear— Remove all tasks.
todo clearclear-completed— Remove only completed tasks.
todo clear-completedstat— Show simple statistics (total, completed, incomplete).
todo statPersistence
- Tasks are persisted to
task.jsonin 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.jsfrom the project directory.
Troubleshooting
- If
todois not found afternpm link, ensure your global npm bin is onPATH, or run:
node index.js <command>