DEV Community

Cover image for timetrace: New features of the time tracking CLI
DB
DB

Posted on

timetrace: New features of the time tracking CLI

Since its initial release in May, a lot of powerful features have been added to timetrace, a simple time tracking CLI. I'm going to introduce some of the features present in timetrace v0.10.0 in this article.

Installing timetrace

If you're on macOS, you can simply use Homebrew:

brew tap dominikbraun/timetrace
brew install timetrace
Enter fullscreen mode Exit fullscreen mode

timetrace is available for all major platforms. Check out the installation instructions and pick yours.

Basic usage: If you're new to timetrace, Tracking my working time using timetrace might be a good read. There also are detailed examples and the CLI reference.

🔥 Project modules

With version 0.7.0, support for project modules has been added to timetrace. Project modules are sub-projects of an existing project.

For example, we could create a project called make-coffee:

timetrace create project make-coffee
Enter fullscreen mode Exit fullscreen mode

Project modules are the exact same thing as projects, expect that they can be associated with a parent project. This association is marked by an @. For example, grind-beans@make-coffee is a module of the project make-coffee. Therefore, creating this project is fairly simple:

timetrace create project grind-beans@make-coffee
Enter fullscreen mode Exit fullscreen mode

timetrace recognizes those modules. For example, when listing all records for a given project, its modules will be included:

timetrace list records today -p make-coffee
+-----+-------------------------+---------+-------+------------+
|  #  |   PROJECT               |  START  |  END  |  BILLABLE  |
+-----+-------------------------+---------+-------+------------+
|   1 | make-coffee             | 08:28   | 08:35 | no         |
|   2 | grind-beans@make-coffee | 08:25   | 08:27 | no         |
+-----+-------------------------+---------+-------+------------+
Enter fullscreen mode Exit fullscreen mode

To view all projects along with their modules, just run timetrace list projects.

🔥 Revert changes to projects and records

timetrace v0.8.0 introduced the --revert flag for the edit project, delete project, edit record and delete record commands. It allows to restore the resource prior to its modification.

For example, let's delete the make-coffee project:

timetrace delete project make-coffee
Enter fullscreen mode Exit fullscreen mode

Oops! That shouldn't have happened. Let's restore the state of the project prior to the delete command:

timetrace delete project make-coffee --revert
Enter fullscreen mode Exit fullscreen mode

The --revert flag reverts the change introduced by the previous command, thus our project exists again.

Edited or deleted records can be restored the exact same way. The following command will edit the newest record and lengthen it by 1 hour:

timetrace edit record latest --plus 1h
Enter fullscreen mode Exit fullscreen mode

This will increase the end time of the records by 1 hour.

Hint: To get a list of the available records of today and the record key for editing them, use timetrace list records today.

If this was a mistake, reverting the previous command is very simple:

timetrace edit record latest --revert
Enter fullscreen mode Exit fullscreen mode

The end time of the record will now be the same as before.

🔥 An enhanced tracking status

The timetrace status command got some love with timetrace v0.9.0 and v0.10.0, addressing some requested features.

First of all, status now not only calculates the overall work time of the current day but also the overall break time. How long have you been taking breaks today? Take a look at the right column!

The current tracking status

Print your custom status

It is also possible to print the tracking status in your custom format using the --format flag. There is a pre-defined set of variables. For example, {project} will be replaced with the name of the current project.

To print an output like Currently working on make-coffee - Worked today: 2h, issue the following command:

timetrace status --format "Currently working on {project} - Worked today: {trackedTimeToday}"
Enter fullscreen mode Exit fullscreen mode

Another new option is --output. It allows the users to specify an output format. The default is the table shown above, but it is also possible to output the same data as JSON:

timetrace status --output json
Enter fullscreen mode Exit fullscreen mode

This will produce the following output:

{
        "project": "web-store",
        "trackedTimeCurrent": "1h 45min",
        "trackedTimeToday": "7h 30min",
        "breakTimeToday": "0h 30min"
}
Enter fullscreen mode Exit fullscreen mode

Note that the JSON keys are the same as the formatting variables used by --format.

This also enables a simple Starship integration.


Now you're good to give those features a try, bookmark the project or provide some feedback!

dominikbraun/timetrace

Top comments (1)

Collapse
 
kishanbsh profile image
Kishan B

I have always used github.com/TailorDev/Watson to perform time tracking.. will definitely try this out