|
|
|
@ -57,7 +57,7 @@ function taskend() { |
|
|
|
function taskuuids() { |
|
|
|
local UUID |
|
|
|
|
|
|
|
[[ $# -eq 0 ]] && set \( +PENDING or +DONE \) |
|
|
|
[[ $# -eq 0 ]] && set -- \( +PENDING or +DONE \) |
|
|
|
for UUID in $(task $@ _uuid) |
|
|
|
do |
|
|
|
printf "%05.2f\037%s\037%s\n" \ |
|
|
|
@ -113,7 +113,7 @@ function extracttime() { |
|
|
|
TIME="00:00:00" |
|
|
|
else |
|
|
|
IFS=: |
|
|
|
set $(echo $1) |
|
|
|
set -- $(echo $1) |
|
|
|
IFS=${OIFS} |
|
|
|
TIMEKEY="$1" |
|
|
|
TIME=$(printf "%02d:%02d:%02d" ${2:-0} ${3:-0} $4) |
|
|
|
@ -125,7 +125,7 @@ function printtimes() { |
|
|
|
for T in "$@" |
|
|
|
do |
|
|
|
extracttime "$T" |
|
|
|
printf "%51s: %s\n" "spent - $TIMEKEY" $TIME |
|
|
|
printf "%51s: %s\n" "spent - $TIMEKEY" "$TIME" |
|
|
|
done |
|
|
|
} |
|
|
|
|
|
|
|
@ -165,20 +165,29 @@ function showall() { |
|
|
|
} |
|
|
|
|
|
|
|
function timesheet() { |
|
|
|
local phrase="1-week-ago" |
|
|
|
local start="$(date +%Y-%m-%d -d ${phrase})" |
|
|
|
local end="$(date +%Y-%m-%d)" |
|
|
|
local PHRASE="1-week-ago" |
|
|
|
local START="$(date +%Y-%m-%d -d ${PHRASE})" |
|
|
|
|
|
|
|
local DONE="$(showall $(doneuuids end.after:${START} $@))" |
|
|
|
local UPCOMING="$(showall $(pendinguuids $@))" |
|
|
|
local BLOCKED="$(showall $(blockeduuids $@))" |
|
|
|
local BLOCKING="$(showall $(blockinguuids $@))" |
|
|
|
|
|
|
|
DONE="${DONE:+${DONE}${NL}}" |
|
|
|
UPCOMING="${UPCOMING:+${UPCOMING}${NL}}" |
|
|
|
BLOCKED="${BLOCKED:+${BLOCKED}${NL}}" |
|
|
|
BLOCKING="${BLOCKING:+${BLOCKING}${NL}}" |
|
|
|
|
|
|
|
printf " (generated at %s)\n\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" \ |
|
|
|
"$(date)" \ |
|
|
|
"$(bold "" "Tasks completed from $start to $end (back $phrase)")" \ |
|
|
|
"$(showall $(doneuuids end.after:${start} $@))" \ |
|
|
|
"${TODAY}" \ |
|
|
|
"$(bold "" "Tasks completed from $START to $TODAY (back $PHRASE)")" \ |
|
|
|
"${DONE}" \ |
|
|
|
"$(bold "" "Upcoming tasks")" \ |
|
|
|
"$(showall $(pendinguuids $@))" \ |
|
|
|
"${UPCOMING}" \ |
|
|
|
"$(bold "" "Blocked tasks")" \ |
|
|
|
"$(showall $(blockeduuids $@))" \ |
|
|
|
"${BLOCKED}" \ |
|
|
|
"$(bold "" "Blocking tasks")" \ |
|
|
|
"$(showall $(blockinguuids $@))" |
|
|
|
"${BLOCKING}" |
|
|
|
|
|
|
|
printf "%s%s\n\n%s%s\n%s\n\n%s\n\n%s\n" \ |
|
|
|
"$(bold "" "Summary")" \ |
|
|
|
@ -190,6 +199,78 @@ function timesheet() { |
|
|
|
"$(task rc._forcecolor=on $@ burndown 2>/dev/null)" |
|
|
|
} |
|
|
|
|
|
|
|
function usage() { |
|
|
|
local USAGE=$(cat <<-USAGE |
|
|
|
Usage: %s [OPTION]... [FILTER] |
|
|
|
|
|
|
|
OPTIONS: |
|
|
|
-?, --help Show this help |
|
|
|
-h, --html Create HTML form ANSI data. |
|
|
|
-f, --file The file to write data to. Actually this specifies the |
|
|
|
basename which will be postfixed by the creation date. |
|
|
|
|
|
|
|
FILTER can be additional taskwarriors filters to limit the result |
|
|
|
any further. |
|
|
|
USAGE |
|
|
|
) |
|
|
|
/usr/bin/printf "${USAGE}\n" $0 |
|
|
|
} |
|
|
|
|
|
|
|
TODAY="$(date +%Y-%m-%d)" |
|
|
|
NL=$'\n' |
|
|
|
|
|
|
|
# |
|
|
|
# parse command line arguments |
|
|
|
# |
|
|
|
SHORTOPTS=?hf: |
|
|
|
LONGOPTS=help,html,file |
|
|
|
ARGS=$(getopt -o "${SHORTOPTS}" --long "${LONGOPTS}" -n "timesheet" -- "$@") |
|
|
|
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 |
|
|
|
;; |
|
|
|
'-h'|'--html') |
|
|
|
DOHTML=1 |
|
|
|
shift |
|
|
|
continue |
|
|
|
;; |
|
|
|
'-f'|'--file') |
|
|
|
OUTFILE="${2}_$TODAY" |
|
|
|
shift 2 |
|
|
|
continue |
|
|
|
;; |
|
|
|
'--') |
|
|
|
shift |
|
|
|
break |
|
|
|
;; |
|
|
|
*) |
|
|
|
echo 'Internal error!' >&2 |
|
|
|
exit 1 |
|
|
|
;; |
|
|
|
esac |
|
|
|
done |
|
|
|
|
|
|
|
[[ $OUTFILE ]] && { |
|
|
|
if [[ ${DOHTML} -eq 1 ]] |
|
|
|
then |
|
|
|
exec 1> >(ansi2html >${OUTFILE}.html) |
|
|
|
else |
|
|
|
exec 1> ${OUTFILE}.ansi |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
timesheet $@ |
|
|
|
|
|
|
|
# vim: set et ts=4 sw=4: |