Here is the source code - https://github.com/Open-EdTech/node-pomodoro
When I started learning about task execution systems like Pomodoro, I thought putting together a CLI myself would be a great way to create a sense of ownership and pride in my work. Also, it would let me ship the features I needed.
- Tracks progress towards completing a given number of hours of work
- Sets goals for continuous work block and break lengths
- Looks nice so productivity streamers can use it
- Emits logs for analysis at a future date
Originally I just made a countdown timer and built off of that. I usually don't write classes, but having a mutable internal state was a really easy way of thinking about the problem.
I'm not very experienced with node.js, so I started by displaying a simple countdown to get my feet wet. The general idea is to use setInterval to set a 1000 millisecond delay between each second on the clock. Originally I used
process.stdout.write but once I found a library for displaying progress bars I realized that the progress bars would be a great way of displaying information about your study goals.
I used enquirer to take the user input.
Here's what it looks like -
The display is simply the multi-progress bar from the CLI-progress library. This is way better than writing to the console yourself. Here's the block I'm on right now -
The code writes to a file in the
sessions folder of the project. The filename is the ending time of the session. The contents look like this -
This way I can perform an analysis at a later date to track the time I spend contributing to open-source.
If you give it a try be sure to read the readme. https://github.com/Open-EdTech/node-pomodoro