From b26818dad13db472b20e299d96d0fb124417a5e6 Mon Sep 17 00:00:00 2001 From: Stepanov Aleksey Date: Sun, 11 May 2025 14:12:21 +0500 Subject: add taskwarrior-tui-scripts project --- lib/project.sh | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 lib/project.sh (limited to 'lib/project.sh') diff --git a/lib/project.sh b/lib/project.sh new file mode 100755 index 0000000..03e322f --- /dev/null +++ b/lib/project.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +#****F* lib/project.sh +# NAME +# +# project.sh - bash-скрипт для создания проекта в taskwarrior-tui. +#****** + +function getProjName() { + task _get "$1".description +} + +function getExitCriteria() { + task _get "$1".annotations.1.description +} + +function taskCheck() { + local task + + task="$1" + annotationCount=$(getAnnotationCount "$task") + + case "$annotationCount" in + 0) + notify "msg-error" "Нет критерия завершения, выход..." + + return 1 + ;; + 1) + notify "msg-error" "Нет первого шага у проекта, выход..." + + return 1 + ;; + *) + checkExistingProject "$task" + hasProject "$task" + + return 0 + ;; + esac +} + +function taskProj() { + local task + local projName + local exitCriteria + local idTask + local tags + + task="$1" + tags=$(getTags "$1") + projName=$(getProjName "$1") + exitCriteria=$(getExitCriteria "$1") + + readarray -t annotations < <(task "$1" export | jq -r '.[] | .annotations[1:] | .[].description') + + if [[ "$tags" =~ "someday" ]]; then + task "$task" modify priority: -someday + fi + + task "$task" modify project:"$projName" description:"$exitCriteria" + + denotateAllAnnotations "$task" + + for taskIndex in "${!annotations[@]}"; do + if [[ "$taskIndex" -eq 0 ]]; then + task add "${annotations[$taskIndex]}" project:"$projName" order:"$((taskIndex + 2))" + + idTask=$(getLatestTaskId) + + continue + fi + + task add "${annotations[$taskIndex]}" project:"$projName" order:"$((taskIndex + 2))" depends:"$idTask" + + idTask=$(getLatestTaskId) + done +} -- cgit