Write a command line script called tasks that allows the user to manage a list
of tasks from the terminal.
Your tasks command should support the following sub-commands:
| command | description | example usage |
|---|---|---|
| add | adds the specified task | ./task.js add Finish reading Flatland |
| list | lists the incomplete tasks | ./task.js list |
| complete | marks the task with id equal to <task-id> complete |
./task.js complete <task-id> |
| delete | deleted the specified task | ./task.js delete <task-id> |
In this 1st version the data for your tasks should be saved to a file called
tasks.json.
- Your command should be called
tasks - The
taskscommand file should have a shebang pointing tonode - The
taskscommand file should have execute permissions - Tasks are persisted to a
jsonfile usingfs.readFileSyncandfs.writeFileSync - The
listcommand is implemented in./commands/list.js - The
addcommand is implemented in./commands/add.js - The
completecommand is implemented in./commands/complete.js - The
deletecommand is implemented in./commands/delete.js - Add tests using Mocha and Chai for all functions
- User receives an error message if they enter an invalid command
- Your program should create the
tasks.jsonif the file doesn't exist tasks.jsonis ignored and not checked into your Git repository
$ ./task.js list
ID Description
-- -----------
You have 0 tasks$ ./task.js add "Buy milk"
Created task 1
$ ./task.js add "Buy eggs"
Created task 2
$ ./task.js add "Bake a cake"
Created task 3
$ ./task.js add "Put groceries in the fridge"
Created task 4
$ ./task.js list
ID Description
-- -----------
1 Buy milk
2 Buy eggs
3 Bake cake
4 Put groceries in the fridge
You have 4 tasks$ ./task.js complete 1
Completed task 1: 'Buy milk'
$ ./task.js delete 2
Deleted task 2: 'Buy eggs'
$ ./task.js list
ID Description
-- -----------
3 Bake cake
4 Put groceries in the fridge
You have 4 tasks