~tardypad/dotfiles

52edb52002d004d9fdc50737a5ed70202c75b268 — Damien Tardy-Panis a month ago 33ca1a0
Rename task and time-tracker description to comment

To make its purpose clearer
M files/configs/zsh/functions/task-log => files/configs/zsh/functions/task-log +4 -4
@@ 9,7 9,7 @@ local day="$1"

[ -n "${day}" ] || day="$( date +%Y-%m-%d )"

local task id name desc duration
local task id name comment duration

task=$(
  task -n ids \


@@ 32,8 32,8 @@ if [ -n "${name}" ]; then
  printf 'Name: %s\n' "${name}"
fi

printf 'Description: '
read -r desc
printf 'Comment: '
read -r comment

while true; do
  printf 'Duration (min): '


@@ 51,4 51,4 @@ done

[ -n "${duration}" ] || return

time-tracker -d "${day}" log "${id}" "${duration}" "${desc}"
time-tracker -d "${day}" log "${id}" "${duration}" "${comment}"

M files/configs/zsh/functions/time-tracker-overview => files/configs/zsh/functions/time-tracker-overview +3 -3
@@ 9,7 9,7 @@ local day="$1"

[ -n "${day}" ] || day="$( date +%Y-%m-%d )"

local line tasks task_id duration desc
local line tasks task_id duration comment

tasks="$( task -n ids )"



@@ 17,7 17,7 @@ time-tracker -d "${day}" -t overview \
  | while read -r line; do
      task_id="$( echo "${line}" | cut -f1 )"
      duration="$( echo "${line}" | cut -f2 )"
      desc="$( echo "${line}" | cut -f3 )"
      comment="$( echo "${line}" | cut -f3 )"

      task_name="$(
        echo "${tasks}" \


@@ 26,6 26,6 @@ time-tracker -d "${day}" -t overview \
      )"

      printf '%s\t%s\t%s\t%s\n' \
        "${task_id}" "${duration}" "${desc}" "${task_name}"
        "${task_id}" "${duration}" "${comment}" "${task_name}"
    done \
  | column -s '	' -t

M files/docs/shell/task.scd => files/docs/shell/task.scd +3 -3
@@ 10,7 10,7 @@ task *create* _id_ [ _name_ ]

task [-n] *ids*

task [-l] *pick* _id_ [ _description_ ]
task [-l] *pick* _id_ [ _comment_ ]

task [-n] *show*



@@ 52,8 52,8 @@ _id_
_name_
	Task name

_description_
	Task description
_comment_
	Task comment

# ENVIRONMENT VARIABLES


M files/docs/shell/time-tracker.scd => files/docs/shell/time-tracker.scd +4 -4
@@ 6,11 6,11 @@ time-tracker - Track and log time spent on a task

# SYNOPSIS

time-tracker *start* _id_ [ _description_ ]
time-tracker *start* _id_ [ _comment_ ]

time-tracker [ *show* | *stop* ]

time-tracker [-d _day_] *log* _id_ _duration_ [ _description_ ]
time-tracker [-d _day_] *log* _id_ _duration_ [ _comment_ ]

time-tracker [-gt] [-d _day_] *overview*



@@ 55,8 55,8 @@ This is the default action if none is specified
_id_
	Task identifier

_description_
	Task description
_comment_
	Task comment

_duration_
	Task duration in minutes

M files/scripts/shell/pick-task => files/scripts/shell/pick-task +5 -5
@@ 40,10 40,10 @@ printf '\n'
printf 'Log [y/N]: '
read -r LOG

TASK_DESC=
TASK_COMMENT=
if [ "${LOG}" = 'Y' ] || [ "${LOG}" = 'y' ]; then
    printf 'Description: '
    read -r TASK_DESC
    printf 'Comment: '
    read -r TASK_COMMENT
fi

printf '\n'


@@ 51,9 51,9 @@ printf 'Do not disturb [y/N]: '
read -r DO_NOT_DISTURB

if [ "${LOG}" = 'Y' ] || [ "${LOG}" = 'y' ]; then
  task -l pick "${TASK_ID}" "${TASK_DESC}"
  task -l pick "${TASK_ID}" "${TASK_COMMENT}"
else
  task pick "${TASK_ID}" "${TASK_DESC}"
  task pick "${TASK_ID}" "${TASK_COMMENT}"
fi

if [ -n "${POMODORO_DURATION}" ]; then

M files/scripts/shell/task => files/scripts/shell/task +3 -3
@@ 9,7 9,7 @@ init_variables() {
  ACTION='show'
  TASK_ID=
  TASK_NAME=
  TASK_DESC=
  TASK_COMMENT=
  LOG=false
  ID_WITH_NAME=false
}


@@ 32,7 32,7 @@ parse_command_line() {
    TASK_NAME="$3"
  elif [ "${ACTION}" = 'pick' ]; then
    TASK_ID="$2"
    TASK_DESC="$3"
    TASK_COMMENT="$3"
  fi
}



@@ 70,7 70,7 @@ task_pick() {
  fi

  if [ "${LOG}" = 'true' ]; then
    time-tracker start "${TASK_ID}" "${TASK_DESC}"
    time-tracker start "${TASK_ID}" "${TASK_COMMENT}"
  fi

  printf '%s' "${TASK_ID}" > "${CURRENT_FILE_PATH}" \

M files/scripts/shell/time-tracker => files/scripts/shell/time-tracker +10 -10
@@ 8,7 8,7 @@ init_variables() {

  ACTION='show'
  TASK_ID=
  TASK_DESC=
  TASK_COMMENT=
  TASK_DURATION=
  LOGGING_DAY=$( date +%Y-%m-%d )
  GROUPED_DISPLAY=false


@@ 31,11 31,11 @@ parse_command_line() {

  if [ "${ACTION}" = 'start' ]; then
    TASK_ID="$2"
    TASK_DESC="$3"
    TASK_COMMENT="$3"
  elif [ "${ACTION}" = 'log' ]; then
    TASK_ID="$2"
    TASK_DURATION="$3"
    TASK_DESC="$4"
    TASK_COMMENT="$4"
  fi
}



@@ 98,7 98,7 @@ time_tracker_start() {
  CURRENT_TIME=$( current_time_min )

  printf '%s\t%s\t%s' \
    "${CURRENT_TIME}" "${TASK_ID}" "${TASK_DESC}" \
    "${CURRENT_TIME}" "${TASK_ID}" "${TASK_COMMENT}" \
    > "${CURRENT_FILE_PATH}"
}



@@ 123,10 123,10 @@ time_tracker_stop() {
  CURRENT_TIME=$( current_time_min )
  CURRENT_DURATION=$(( CURRENT_TIME - START_TIME ))
  CURRENT_ID=$( cut -f 2 "${CURRENT_FILE_PATH}" )
  CURRENT_DESC=$( cut -f 3 "${CURRENT_FILE_PATH}" )
  CURRENT_COMMENT=$( cut -f 3 "${CURRENT_FILE_PATH}" )

  printf '%s\t%s\t%s\n' \
    "${CURRENT_ID}" "${CURRENT_DURATION}" "${CURRENT_DESC}" \
    "${CURRENT_ID}" "${CURRENT_DURATION}" "${CURRENT_COMMENT}" \
    >> "${LOGGING_DIR}/${CURRENT_DAY}"

  rm -rf "${CURRENT_FILE_PATH}"


@@ 139,7 139,7 @@ is_tracking_task() {
time_tracker_log()
{
  printf '%s\t%s\t%s\n' \
    "${TASK_ID}" "${TASK_DURATION}" "${TASK_DESC}" \
    "${TASK_ID}" "${TASK_DURATION}" "${TASK_COMMENT}" \
    >> "${LOGGING_DIR}/${LOGGING_DAY}"
}



@@ 168,12 168,12 @@ time_tracker_overview()
  awk -v FS='\t' -v OFS='\t' \
    '{
      sum[$1] += $2;
      if ($3 && desc[$1] !~ $3", ")
        desc[$1] = desc[$1] $3", "
      if ($3 && comment[$1] !~ $3", ")
        comment[$1] = comment[$1] $3", "
     }
    END {
      for (id in sum)
      print id, sum[id], desc[id]
      print id, sum[id], comment[id]
    }' \
    "${LOGGING_DIR}/${LOGGING_DAY}" \
    | sed 's/, $//' \