Commit b5be13ecf1b01bf5dd5e67f0eebaca7c11e6635a
1 parent
ba3541b9
Fix display when no times are tracked for now
Showing
2 changed files
with
22 additions
and
14 deletions
| ... | ... | @@ -31,14 +31,14 @@ function uuids() { |
| 31 | 31 | function worktimes() { |
| 32 | 32 | [[ $# -eq 0 ]] && return 1 |
| 33 | 33 | |
| 34 | - local WHEN='\([^ ]*\) \([^ ]*\)' | |
| 35 | - local DUR='.*duration: \(\([0-9]*\)d \)\?\([^)]*\)' | |
| 36 | - local OUT='{"uuid":"'"$1"'","stop":"\1T\2Z","duration":"\4:\5"}' | |
| 34 | + local PWHEN='\([^ ]*\) \([^ ]*\)' | |
| 35 | + local PDUR='.*duration: \(\([0-9]*\)d \)\?\([^)]*\)' | |
| 36 | + local POUT='{"uuid":"'"$1"'","stop":"\1T\2Z","duration":"\4:\5"}' | |
| 37 | 37 | local TIME DAYS |
| 38 | 38 | |
| 39 | 39 | echo '[' |
| 40 | 40 | task $1 info|\ |
| 41 | - sed 's/'"${WHEN}${DUR}"'.*/'"${OUT}"'/;te;d;:e'|\ | |
| 41 | + sed 's/'"${PWHEN}${PDUR}"'.*/'"${POUT}"'/;te;d;:e'|\ | |
| 42 | 42 | while read TIME; do |
| 43 | 43 | DUR="$(echo "${TIME}"|jq -r '.duration')" |
| 44 | 44 | DAYS="${DUR%%:*}" |
| ... | ... | @@ -69,6 +69,9 @@ function work() { |
| 69 | 69 | done |
| 70 | 70 | done |
| 71 | 71 | |
| 72 | + DAYS=${DAYS:-0} | |
| 73 | + SECS=${SECS:-0} | |
| 74 | + | |
| 72 | 75 | printf '{"uuid":"%s","times":%s,"total":"%s:%s"}'\ |
| 73 | 76 | ${UUID} "${TIMES}" ${DAYS} $(date +%H:%M:%S -u -d@${SECS}) |
| 74 | 77 | } |
| ... | ... | @@ -79,6 +82,9 @@ function flattened_work() { |
| 79 | 82 | WORK="$(work $1)" |
| 80 | 83 | ITEM="$(echo "${WORK}"|jq -M -c '.|del(.times)')" |
| 81 | 84 | |
| 85 | + # If there are no TIMES logged then this will be empty at all. | |
| 86 | + # The only remaining information in that case would have been the | |
| 87 | + # UUID. But the caller already know it. | |
| 82 | 88 | echo "${WORK}"|jq -M -c '.times|map(.+'"${ITEM}"')' |
| 83 | 89 | } |
| 84 | 90 | ... | ... |
| ... | ... | @@ -27,7 +27,7 @@ function showall() { |
| 27 | 27 | eval set -- ${W} |
| 28 | 28 | |
| 29 | 29 | if [[ ${NO} -eq 1 ]]; then |
| 30 | - local TIME="$(formattime $4)" | |
| 30 | + local TIME="$(formattime ${4:-0:00:00:00})" | |
| 31 | 31 | local PROJECT="$(task _get $UUID.project)" |
| 32 | 32 | |
| 33 | 33 | printf "%-10.10s %-33.33s %s %-10.10s %-10.10s\n" \ |
| ... | ... | @@ -38,14 +38,16 @@ function showall() { |
| 38 | 38 | "$(todate $(task _get $UUID.entry))" |
| 39 | 39 | fi |
| 40 | 40 | |
| 41 | - if [[ ${NO} -eq ${UNITS} ]]; then | |
| 42 | - printf "└─ %s %13.13s\n" \ | |
| 43 | - "$(timestring "$1" "$2")" \ | |
| 44 | - "$(formattime $2)" | |
| 45 | - else | |
| 46 | - printf "├─ %s %13.13s\n" \ | |
| 47 | - "$(timestring "$1" "$2")" \ | |
| 48 | - "$(formattime $2)" | |
| 41 | + if [[ $# -ne 0 ]]; then | |
| 42 | + if [[ ${NO} -eq ${UNITS} ]]; then | |
| 43 | + printf "└─ %s %13.13s\n" \ | |
| 44 | + "$(timestring "$1" "$2")" \ | |
| 45 | + "$(formattime $2)" | |
| 46 | + else | |
| 47 | + printf "├─ %s %13.13s\n" \ | |
| 48 | + "$(timestring "$1" "$2")" \ | |
| 49 | + "$(formattime $2)" | |
| 50 | + fi | |
| 49 | 51 | fi |
| 50 | 52 | NO=$((NO+1)) |
| 51 | 53 | done |
| ... | ... | @@ -90,7 +92,7 @@ function timesheet() { |
| 90 | 92 | "${TODAY}" \ |
| 91 | 93 | "$(bold "" "Tasks completed from $START to $TODAY (back $PHRASE)")" \ |
| 92 | 94 | "${DONE}" \ |
| 93 | - "$(bold "" "Upcoming tasks")" \ | |
| 95 | + "$(bold "" "Current tasks")" \ | |
| 94 | 96 | "${UPCOMING}" \ |
| 95 | 97 | "$(bold "" "Blocked tasks")" \ |
| 96 | 98 | "${BLOCKED}" \ | ... | ... |
Please
register
or
login
to post a comment