dominikbraun / timetrace

A simple CLI for tracking your working time.
Apache License 2.0
685 stars 76 forks source link

Add --format optional arg #94

Closed nymann closed 3 years ago

nymann commented 3 years ago

Hey, thanks for this awesome tool! Makes the time tracking part of my life easier :+1:

Right now I have the current task that I am working on in my status bar.

timetrace status | awk -F'|' 'NR == 4 {gsub(/ /, "", $0); print $2 " " $3}'

And this works, but it would be nice to add a format parameter to timetrace status to fx format the output as JSON, which is easier to work with in scripts :-)

dominikbraun commented 3 years ago

We're planning to implement this feature as an --output (short -o) flag that accepts json as a value:

timetrace status -o json

This would exactly match the way we'll be printing reports as JSON/CSV, see https://github.com/dominikbraun/timetrace/issues/88#issuecomment-850388905.

The --format flag will be introduced by #109, and it allows to specify a custom output format.

dominikbraun commented 3 years ago

Hi,

so timetrace 0.10.0 now supports the --format flag for printing the status in your custom format and the --output flag for specifying JSON as output format.

You can find the available formatting variables and further examples in the status command reference:

Variable Description
{project} The key of the current project.
{trackedTimeCurrent} The time tracked for the current record.
{trackedTimeToday} The time tracked today.
{breakTimeToday} The break time since the first record.

Hope this helps!