#!/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 }