This is a project from the roadmap.sh web page. It is made using their instructions and requirements.
I've implemented the solution using NodeJS and it's only dependency is colors
and prompt-sync
, coding all the rest of functions with native NodeJS tools
To set up the project first clone the repository using
git clone https://github.com/Roky3029/taskCli
and then get inside the folder using cd taskCli
and as you can see inside the package.json
, once you are inside the folder, just execute the command
npm i -g .
(On Linux based distros you may have to execute it with sudo in order to install it globally)
- This will install globally on your computer the CLI and to execute it once it has finished, just use the command
task
followed by the arguments required.
Important
Before installing globally the package, if you wish to modify the command, you can do so by going to the package.json
file and modifying the following section:
"bin": {
"task": "./index.js"
},
By changing the "task"
key you will be able to use your desired command
Full command: task <action> <id | text | status>
- Action list:
Action | Description |
---|---|
add |
Adds a new task to the list |
update |
Updates the text of the specified task |
delete |
Deletes the task |
mark-in-progress |
Sets the task status to "In progress" |
mark-done |
Sets the task status to "Done" |
list |
Gives a list with all the tasks (or the tasks with a certain status if given) |
-
If the action is
add
the next parameter must be the text that will be added to the task.
Example:task add "Fix the bug and commit"
-
If the action is
update
,delete
,mark-in-progress
ormark-done
the following parameter must be the task ID
(In the update command this must be then followed by the updated task name)
Examples:task update 1 "Set up the DB"
task mark-done 3
-
Finally, if the action is
list
, this can be used astask list
which will display all tasks created, but it can also be given one of the three task status to filter and display just the tasks with that status (done
,todo
orin-progress
).
Example:task list todo
Caution
If you attempt to modify the tasks.json
and you happen to break it and make it unmodifiable by the program, you must delete the file and start again, this will create a new error-free file
Each task has the following structure:
{
id: "Unique identifier for the task" <number>,
description: "The task's text" <string>,
status: "The task's status" <'done' | 'todo' | 'in-progress'>,
createdAt: "The date when the task was initially created" <Date>,
updatedAt: "The last time the task was updated" <Date>
}
Hi, I'm Miguel and I love coding things and learning new skills. If you want to reach me, you can check out my social networks: