aboutsummaryrefslogtreecommitdiff
path: root/lib/project.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/project.sh')
-rwxr-xr-xlib/project.sh78
1 files changed, 78 insertions, 0 deletions
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
+}