Browse Source

Options and Arguments for report

master
Georg Hopp 8 years ago
parent
commit
7b10c057cb
Signed by: ghopp GPG Key ID: 4C5D226768784538
  1. 81
      timesheet/report.sh

81
timesheet/report.sh

@ -6,35 +6,44 @@ source $0:A:h/ttyhelper.sh
function tasksallsince() { function tasksallsince() {
[[ $# -lt 1 ]] && return 1 [[ $# -lt 1 ]] && return 1
local DATE=$1
shift
taskuuids \( \( \( +COMPLETED or +DELETED \) end.after:$DATE \) or \
+PENDING \) $@
taskuuids \(\(\( +COMPLETED or +DELETED \) end.after:${1} \) \
or +PENDING \) $@
} }
function datetimedescription() { function datetimedescription() {
for UUID in $(tasksallsince 2018-03-31)
[[ $# -lt 1 ]] && return 1
for UUID in $(tasksallsince $@)
do do
DESCRIPTION="$(taskdescription $UUID)" DESCRIPTION="$(taskdescription $UUID)"
PROJECT="$(taskproject $UUID)" PROJECT="$(taskproject $UUID)"
COMPLETED="$(taskuuids $UUID \( +COMPLETED or +DELETED \))"
for T in $(tasktimes $UUID) for T in $(tasktimes $UUID)
do do
extracttime $T extracttime $T
printf "%s;%s;%s;%s\n" $TIMEKEY $TIME $PROJECT $DESCRIPTION
printf "%s;%s;%s;%s;%s\n" \
$TIMEKEY $TIME $PROJECT $DESCRIPTION $COMPLETED
done done
done done
} }
function report() { function report() {
for LINE in "${(f)$(datetimedescription|sort -t\; -k1)}"
[[ $# -lt 1 ]] && return 1
local D DATE T
DATE=$1
for LINE in "${(f)$(datetimedescription $@|sort -t\; -f -k1,1 -k3,3)}"
do do
set -- ${(s(;))LINE} set -- ${(s(;))LINE}
if [[ $DATE != $1 ]]
then
DATE=$1
printf "%s\n" $(underline "" $DATE)
fi
printf "%s [%s] - %s\n" $(bold "" $2) $3 $4
if [[ -n $1 && $(date -d $1 +%s) -ge $(date -d $DATE +%s) ]]
then
if [[ $D != $1 ]]
then
D=$1
printf "%s\n" $(underline "" $D)
fi
T=$2
if [[ -n $5 ]] && T=$(bold "" $T)
if [[ -n $D ]] && printf "%s [%s] - %s\n" $T $3 $4
fi
done done
} }
@ -44,15 +53,57 @@ function usage() {
OPTIONS: OPTIONS:
-?, --help Show this help -?, --help Show this help
-d, --date DATETIME is a date and time identifier as accepted by the
date command. It specifies how long back done tasks
should be considered.
FILTER can be additional taskwarriors filters to limit the result FILTER can be additional taskwarriors filters to limit the result
any further. any further.
DATETIME is a date and time identifier as accepted by the date command.
It specifies how long back done tasks should be considered.
USAGE USAGE
) )
/usr/bin/printf "${USAGE}\n" $0 /usr/bin/printf "${USAGE}\n" $0
} }
#
# parse command line arguments
#
SHORTOPTS=?d:
LONGOPTS=help,date
ARGS=$(getopt -o ${SHORTOPTS} --long ${LONGOPTS} -n report -- $@)
if [ $? -ne 0 ]
then
usage $0
exit 1
fi
eval set -- ${=ARGS}
unset ARGS
while true
do
case $1 in
'-?'|'--help')
shift
usage $0
exit 0
;;
'-d'|'--date')
DATEFROM=$(date -d ${2} +%Y-%m-%d)
shift 2
continue
;;
'--')
shift
break
;;
*)
echo 'Internal error!' >&2
exit 1
;;
esac
done
DATEFROM=${DATEFROM:-$(date +%Y-%m-01)}
report $DATEFROM $@
#datetimedescription $DATEFROM $@|sort -t\; -f -k1,1 -k3,3
# vim: set et ts=4 sw=4: # vim: set et ts=4 sw=4:
Loading…
Cancel
Save