Showing
1 changed file
with
58 additions
and
0 deletions
timesheet/report.sh
0 → 100755
| 1 | +#!/bin/zsh | ||
| 2 | + | ||
| 3 | +source $0:A:h/datetimehelper.sh | ||
| 4 | +source $0:A:h/taskhelper.sh | ||
| 5 | +source $0:A:h/ttyhelper.sh | ||
| 6 | + | ||
| 7 | +function tasksallsince() { | ||
| 8 | + [[ $# -lt 1 ]] && return 1 | ||
| 9 | + local DATE=$1 | ||
| 10 | + shift | ||
| 11 | + taskuuids \( \( \( +COMPLETED or +DELETED \) end.after:$DATE \) or \ | ||
| 12 | + +PENDING \) $@ | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +function datetimedescription() { | ||
| 16 | + for UUID in $(tasksallsince 2018-03-31) | ||
| 17 | + do | ||
| 18 | + DESCRIPTION="$(taskdescription $UUID)" | ||
| 19 | + PROJECT="$(taskproject $UUID)" | ||
| 20 | + for T in $(tasktimes $UUID) | ||
| 21 | + do | ||
| 22 | + extracttime $T | ||
| 23 | + printf "%s;%s;%s;%s\n" $TIMEKEY $TIME $PROJECT $DESCRIPTION | ||
| 24 | + done | ||
| 25 | + done | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +function report() { | ||
| 29 | + for LINE in "${(f)$(datetimedescription|sort -t\; -k1)}" | ||
| 30 | + do | ||
| 31 | + set -- ${(s(;))LINE} | ||
| 32 | + if [[ $DATE != $1 ]] | ||
| 33 | + then | ||
| 34 | + DATE=$1 | ||
| 35 | + printf "%s\n" $(underline "" $DATE) | ||
| 36 | + fi | ||
| 37 | + printf "%s [%s] - %s\n" $(bold "" $2) $3 $4 | ||
| 38 | + done | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +function usage() { | ||
| 42 | + local USAGE=$(cat <<-USAGE | ||
| 43 | + Usage: %s [-?] [DATETIME] [FILTER] | ||
| 44 | + | ||
| 45 | + OPTIONS: | ||
| 46 | + -?, --help Show this help | ||
| 47 | + | ||
| 48 | + FILTER can be additional taskwarriors filters to limit the result | ||
| 49 | + any further. | ||
| 50 | + DATETIME is a date and time identifier as accepted by the date command. | ||
| 51 | + It specifies how long back done tasks should be considered. | ||
| 52 | + USAGE | ||
| 53 | + ) | ||
| 54 | + /usr/bin/printf "${USAGE}\n" $0 | ||
| 55 | +} | ||
| 56 | + | ||
| 57 | + | ||
| 58 | +# vim: set et ts=4 sw=4: |
Please
register
or
login
to post a comment