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 --- docs/edit_project_sh.html | 43 ++++++ docs/jtx_sh.html | 43 ++++++ docs/lib/environment_sh.html | 92 +++++++++++++ docs/lib/global_sh.html | 218 +++++++++++++++++++++++++++++++ docs/lib/project_sh.html | 43 ++++++ docs/masterindex.html | 63 +++++++++ docs/robo_definitions.html | 43 ++++++ docs/robo_dirs.html | 40 ++++++ docs/robo_files.html | 44 +++++++ docs/robo_functions.html | 46 +++++++ docs/robo_modules.html | 40 ++++++ docs/robo_sourcefiles.html | 64 +++++++++ docs/robodoc.css | 302 +++++++++++++++++++++++++++++++++++++++++++ docs/robodoc.js | 10 ++ docs/toc_index.html | 63 +++++++++ docs/tskw_sh.html | 58 +++++++++ edit_project.sh | 30 +++++ jtx.sh | 46 +++++++ lib/edit.sh | 107 +++++++++++++++ lib/environment.sh | 43 ++++++ lib/global.sh | 265 +++++++++++++++++++++++++++++++++++++ lib/project.sh | 78 +++++++++++ robodoc.rc | 49 +++++++ tskw.sh | 58 +++++++++ 24 files changed, 1888 insertions(+) create mode 100644 docs/edit_project_sh.html create mode 100644 docs/jtx_sh.html create mode 100644 docs/lib/environment_sh.html create mode 100644 docs/lib/global_sh.html create mode 100644 docs/lib/project_sh.html create mode 100644 docs/masterindex.html create mode 100644 docs/robo_definitions.html create mode 100644 docs/robo_dirs.html create mode 100644 docs/robo_files.html create mode 100644 docs/robo_functions.html create mode 100644 docs/robo_modules.html create mode 100644 docs/robo_sourcefiles.html create mode 100644 docs/robodoc.css create mode 100644 docs/robodoc.js create mode 100644 docs/toc_index.html create mode 100644 docs/tskw_sh.html create mode 100755 edit_project.sh create mode 100755 jtx.sh create mode 100755 lib/edit.sh create mode 100755 lib/environment.sh create mode 100755 lib/global.sh create mode 100755 lib/project.sh create mode 100644 robodoc.rc create mode 100755 tskw.sh diff --git a/docs/edit_project_sh.html b/docs/edit_project_sh.html new file mode 100644 index 0000000..b3ff28a --- /dev/null +++ b/docs/edit_project_sh.html @@ -0,0 +1,43 @@ + + + + + + + + +edit_project.sh + + + + + + +
+
+ +

./edit_project.sh [ Files ]

+ +

[ Top ] [ Files ]

+

NAME

+

edit_project.sh - bash-скрипт для редактирования проекта в taskwarrior-tui. +

+ +
+ + + diff --git a/docs/jtx_sh.html b/docs/jtx_sh.html new file mode 100644 index 0000000..e0d0789 --- /dev/null +++ b/docs/jtx_sh.html @@ -0,0 +1,43 @@ + + + + + + + + +jtx.sh + + + + + + +
+
+ +

./jtx.sh [ Files ]

+ +

[ Top ] [ Files ]

+

NAME

+

jtx.sh - bash-скрипт для работы с мобильным приложением jtxBoard. +

+ +
+ + + diff --git a/docs/lib/environment_sh.html b/docs/lib/environment_sh.html new file mode 100644 index 0000000..792b83b --- /dev/null +++ b/docs/lib/environment_sh.html @@ -0,0 +1,92 @@ + + + + + + + + +environment.sh + + + + + + +
+
+ +

lib/environment.sh [ Files ]

+ +

[ Top ] [ lib ] [ Files ]

+

NAME

+

environment - файл c основными константами и переменными. +

+

USED BY

+ +

+ +
+ +

environment.sh/FOOTE [ Definitions ]

+ +

[ Top ] [ environment.sh ] [ Definitions ]

+

NAME

+

FOOTE - bash-скрипт $HOME/bin/foote.sh. +

+ +
+ +

environment.sh/LIB_DIR [ Definitions ]

+ +

[ Top ] [ environment.sh ] [ Definitions ]

+

NAME

+

LIB_DIR - папка с вспомогательными функциями. +

+ +
+ +

environment.sh/PEACLOCK_CUSTOM_CONFIG [ Definitions ]

+ +

[ Top ] [ environment.sh ] [ Definitions ]

+

NAME

+

PEACLOCK_CUSTOM_CONFIG - кастомный файл конфигурации для peaclock. +

+ +
+ +

environment.sh/ROOT_DIR [ Definitions ]

+ +

[ Top ] [ environment.sh ] [ Definitions ]

+

NAME

+

ROOT_DIR - корень проекта. +

+ +
+ + + diff --git a/docs/lib/global_sh.html b/docs/lib/global_sh.html new file mode 100644 index 0000000..3600ff8 --- /dev/null +++ b/docs/lib/global_sh.html @@ -0,0 +1,218 @@ + + + + + + + + +global.sh + + + + + + +
+
+ +

lib/global.sh [ Files ]

+ +

[ Top ] [ lib ] [ Files ]

+

NAME

+

global.sh - общие функции для всех скриптов. +

+

USES

+ +

+ +
+ +

global.sh/checkExistingProject [ Functions ]

+ +

[ Top ] [ global.sh ] [ Functions ]

+

NAME

+

checkExistingProject - проверка на наличие существующего проекта. +

+

ARGUMENTS

+
# id | uuid - id или uuid задачи.
+
+

USAGE

+
# checkExistingProject <id | uuid>
+
+

USES

+ +

+ +
+ +

global.sh/denotateAllAnnotations [ Functions ]

+ +

[ Top ] [ global.sh ] [ Functions ]

+

NAME

+

denotateAllAnnotations - удаление всех аннотаций у задачи. +

+

ARGUMENTS

+
# id | uuid - id или uuid задачи.
+
+

USAGE

+
# denotateAllAnnotations <id | uuid>
+
+

USES

+ +

+ +
+ +

global.sh/getAnnotationCount [ Functions ]

+ +

[ Top ] [ global.sh ] [ Functions ]

+

NAME

+

getAnnotationCount - возвращает длину массива аннотаций задачи. +

+

ARGUMENTS

+
# id | uuid - id или uuid задачи.
+
+

USAGE

+
# getAnnotationCount <id | uuid>
+
+

RETURN VALUE

+
# return {String} - Количество аннотаций
+
+

USES

+ +

+ +
+ +

global.sh/getLatestTaskId [ Functions ]

+ +

[ Top ] [ global.sh ] [ Functions ]

+

NAME

+

getLatestTaskId - возвращает id задачи. +

+

DESCRIPTION

+

Возвращает id задачи с тегом +LATEST, которая является самой последней из добавленных. +

+

RETURN VALUE

+
# return {string} - Id задачи
+
+

USES

+ +

+

NOTES

+
 https://taskwarrior.org/docs/tags/
+
+ +
+ +

global.sh/getTags [ Functions ]

+ +

[ Top ] [ global.sh ] [ Functions ]

+

NAME

+

getTags - возвращает массив тегов задачи. +

+

ARGUMENTS

+
# id | uuid - id или uuid задачи.
+
+

USAGE

+
# getTags <id | uuid>
+
+

RETURN VALUE

+
# return {Array} - Массив тегов
+
+

USES

+ +

+ +
+ +

global.sh/hasProject [ Functions ]

+ +

[ Top ] [ global.sh ] [ Functions ]

+

NAME

+

hasProject - проверка на наличие проекта у задачи. +

+

ARGUMENTS

+
# id | uuid - id или uuid задачи.
+
+

USAGE

+
# hasProject <id | uuid>
+
+

USES

+ +

+ +
+ +

global.sh/notify [ Functions ]

+ +

[ Top ] [ global.sh ] [ Functions ]

+

NAME

+

notify - вывод сообщения через notify-send. +

+

ARGUMENTS

+
# category - категория уведомления.
+# message - строка сообщения.
+
+

USAGE

+
# notify <category> <message>
+
+

EXAMPLE

+
# notify "msg-error" "Ошибка!"
+
+

USES

+ +

+

NOTES

+
 Категории уведомлений находятся в $HOME/.config/mako/category
+
+ +
+ + + diff --git a/docs/lib/project_sh.html b/docs/lib/project_sh.html new file mode 100644 index 0000000..aded21a --- /dev/null +++ b/docs/lib/project_sh.html @@ -0,0 +1,43 @@ + + + + + + + + +project.sh + + + + + + +
+
+ +

lib/project.sh [ Files ]

+ +

[ Top ] [ lib ] [ Files ]

+

NAME

+

project.sh - общие функции для всех скриптов. +

+ +
+ + + diff --git a/docs/masterindex.html b/docs/masterindex.html new file mode 100644 index 0000000..073d5bf --- /dev/null +++ b/docs/masterindex.html @@ -0,0 +1,63 @@ + + + + + + + + +Index + + + + + +
+
+ +
+

Index

+

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+

C

checkExistingProject +

D

denotateAllAnnotations +

E

edit_project.sh +edit_project.sh +environment.sh +environment.sh +

F

FOOTE +

G

getAnnotationCount +getLatestTaskId +getTags +global.sh +global.sh +

H

hasProject +

J

jtx.sh +jtx.sh +

L

lib +LIB_DIR +

N

notify +

P

PEACLOCK_CUSTOM_CONFIG +project.sh +project.sh +

R

ROOT_DIR +

T

tskw.sh +tskw.sh +

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+
+ + + diff --git a/docs/robo_definitions.html b/docs/robo_definitions.html new file mode 100644 index 0000000..e250df9 --- /dev/null +++ b/docs/robo_definitions.html @@ -0,0 +1,43 @@ + + + + + + + + +Definitions + + + + + +
+
+ +
+

Definitions

+

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+

F

FOOTE +

L

LIB_DIR +

P

PEACLOCK_CUSTOM_CONFIG +

R

ROOT_DIR +

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+
+ + + diff --git a/docs/robo_dirs.html b/docs/robo_dirs.html new file mode 100644 index 0000000..6b10f02 --- /dev/null +++ b/docs/robo_dirs.html @@ -0,0 +1,40 @@ + + + + + + + + +Directories + + + + + +
+
+ +
+

Directories

+

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+

L

lib +

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+
+ + + diff --git a/docs/robo_files.html b/docs/robo_files.html new file mode 100644 index 0000000..b3d0217 --- /dev/null +++ b/docs/robo_files.html @@ -0,0 +1,44 @@ + + + + + + + + +Files + + + + + +
+
+ +
+

Files

+

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+

E

edit_project.sh +environment.sh +

G

global.sh +

J

jtx.sh +

P

project.sh +

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+
+ + + diff --git a/docs/robo_functions.html b/docs/robo_functions.html new file mode 100644 index 0000000..7a0ab3c --- /dev/null +++ b/docs/robo_functions.html @@ -0,0 +1,46 @@ + + + + + + + + +Functions + + + + + +
+
+ +
+

Functions

+

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+

C

checkExistingProject +

D

denotateAllAnnotations +

G

getAnnotationCount +getLatestTaskId +getTags +

H

hasProject +

N

notify +

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+
+ + + diff --git a/docs/robo_modules.html b/docs/robo_modules.html new file mode 100644 index 0000000..b337f30 --- /dev/null +++ b/docs/robo_modules.html @@ -0,0 +1,40 @@ + + + + + + + + +Modules + + + + + +
+
+ +
+

Modules

+

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+

T

tskw.sh +

A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9

+
+ + + diff --git a/docs/robo_sourcefiles.html b/docs/robo_sourcefiles.html new file mode 100644 index 0000000..67bbc6a --- /dev/null +++ b/docs/robo_sourcefiles.html @@ -0,0 +1,64 @@ + + + + + + + + +Sourcefiles + + + + + +
+
+ +
+ +
+ + + diff --git a/docs/robodoc.css b/docs/robodoc.css new file mode 100644 index 0000000..207a172 --- /dev/null +++ b/docs/robodoc.css @@ -0,0 +1,302 @@ +/****h* ROBODoc/ROBODoc Cascading Style Sheet + * FUNCTION + * This is the default cascading style sheet for documentation + * generated with ROBODoc. + * You can edit this file to your own liking and then use + * it with the option + * --css + * + * This style-sheet defines the following layout + * +----------------------------------------+ + * | logo | + * +----------------------------------------+ + * | extra | + * +----------------------------------------+ + * | | navi- | + * | | gation | + * | content | | + * | | | + * +----------------------------------------+ + * | footer | + * +----------------------------------------+ + * + * This style-sheet is based on a style-sheet that was automatically + * generated with the Strange Banana stylesheet generator. + * See http://www.strangebanana.com/generator.aspx + * + ****** + * $Id: html_generator.c,v 1.94 2008/06/17 11:49:27 gumpu Exp $ + */ + +body +{ + background-color: rgb(255,255,255); + color: rgb(98,84,55); + font-family: Arial, serif; + border-color: rgb(226,199,143); +} + +pre +{ + font-family: monospace; + margin: 15px; + padding: 5px; + white-space: pre; + color: #000; +} + +pre.source +{ + background-color: #ffe; + border: dashed #aa9 1px; +} + +p +{ + margin:15px; +} + +p.item_name +{ + font-weight: bolder; + margin:5px; + font-size: 120%; +} + +#content +{ + font-size: 100%; + color: rgb(0,0,0); + background-color: rgb(255,255,255); + border-left-width: 0px; + border-right-width: 0px; + border-top-width: 0px; + border-bottom-width: 0px; + border-left-style: none; + border-right-style: none; + border-top-style: none; + border-bottom-style: none; + padding: 40px 31px 14px 17px; + border-color: rgb(0,0,0); + text-align: justify; +} + +#navigation +{ + background-color: rgb(98,84,55); + color: rgb(230,221,202); + font-family: "Times New Roman", serif; + font-style: normal; + border-color: rgb(0,0,0); +} + +a.menuitem +{ + font-size: 120%; + background-color: rgb(0,0,0); + color: rgb(195,165,100); + font-variant: normal; + text-transform: none; + font-weight: normal; + padding: 1px 8px 3px 1px; + margin-left: 5px; + margin-right: 5px; + margin-top: 5px; + margin-bottom: 5px; + border-color: rgb(159,126,57); + text-align: right; +} + +#logo, #logo a +{ + font-size: 130%; + background-color: rgb(198,178,135); + color: rgb(98,84,55); + font-family: Georgia, serif; + font-style: normal; + font-variant: normal; + text-transform: none; + font-weight: bold; + padding: 20px 18px 20px 18px; + border-color: rgb(255,255,255); + text-align: right; +} + +#extra, #extra a +{ + font-size: 128%; + background-color: rgb(0,0,0); + color: rgb(230,221,202); + font-style: normal; + font-variant: normal; + text-transform: none; + font-weight: normal; + border-left-width: 0px; + border-right-width: 0px; + border-top-width: 0px; + border-bottom-width: 0px; + border-left-style: none; + border-right-style: none; + border-top-style: none; + border-bottom-style: none; + padding: 12px 12px 12px 12px; + border-color: rgb(195,165,100); + text-align: center; +} + +#content a +{ + color: rgb(159,126,57); + text-decoration: none; +} + +#content a:hover, #content a:active +{ + color: rgb(255,255,255); + background-color: rgb(159,126,57); +} + +a.indexitem +{ + display: block; +} + +h1, h2, h3, h4, h5, h6 +{ + background-color: rgb(221,221,221); + font-family: Arial, serif; + font-style: normal; + font-variant: normal; + text-transform: none; + font-weight: normal; +} + +h1 +{ + font-size: 151%; +} + +h2 +{ + font-size: 142%; +} + +h3 +{ + font-size: 133%; +} + +h4 +{ + font-size: 124%; +} + +h5 +{ + font-size: 115%; +} + +h6 +{ + font-size: 106%; +} + +#navigation a +{ + text-decoration: none; +} + +.menuitem:hover +{ + background-color: rgb(195,165,100); + color: rgb(0,0,0); +} + +#extra a +{ + text-decoration: none; +} + +#logo a +{ + text-decoration: none; +} + +#extra a:hover +{ +} + +/* layout */ +#navigation +{ + width: 22%; + position: relative; + top: 0; + right: 0; + float: right; + text-align: center; + margin-left: 10px; +} + +.menuitem {width: auto;} +#content {width: auto;} +.menuitem {display: block;} + + +div#footer +{ + background-color: rgb(198,178,135); + color: rgb(98,84,55); + clear: left; + width: 100%; + font-size: 71%; +} + +div#footer a +{ + background-color: rgb(198,178,135); + color: rgb(98,84,55); +} + +div#footer p +{ + margin:0; + padding:5px 10px +} + +span.keyword +{ + color: #00F; +} + +span.comment +{ + color: #080; +} + +span.quote +{ + color: #F00; +} + +span.squote +{ + color: #F0F; +} + +span.sign +{ + color: #008B8B; +} + +span.line_number +{ + color: #808080; +} + +@media print +{ + #navigation {display: none;} + #content {padding: 0px;} + #content a {text-decoration: underline;} +} diff --git a/docs/robodoc.js b/docs/robodoc.js new file mode 100644 index 0000000..4912c05 --- /dev/null +++ b/docs/robodoc.js @@ -0,0 +1,10 @@ +/****h* ROBODoc/ROBODoc Javascript support + * FUNCTION + * This is the default Javascript library for documentation + * generated with ROBODoc. + * You can edit this file to your own liking and then use + * it with the option + * --js + ****** + * $Id: html_generator.c,v 1.95 2019/01/04 23:58:00 cashy Exp $ + */ diff --git a/docs/toc_index.html b/docs/toc_index.html new file mode 100644 index 0000000..721f2a4 --- /dev/null +++ b/docs/toc_index.html @@ -0,0 +1,63 @@ + + + + + + + + +Table of Contents + + + + + +
+
+ + + + + diff --git a/docs/tskw_sh.html b/docs/tskw_sh.html new file mode 100644 index 0000000..1a17924 --- /dev/null +++ b/docs/tskw_sh.html @@ -0,0 +1,58 @@ + + + + + + + + +tskw.sh + + + + + + +
+
+ +

taskwarrior-tui-scripts/lib [ Directories ]

+ +

[ Top ] [ Directories ]

+

NAME

+

lib - папка с вспомогательными функциями. +

+ +
+ +

taskwarrior-tui-scripts/tskw.sh [ Modules ]

+ +

[ Top ] [ Modules ]

+

NAME

+

tskw.sh - основной выполняемый файл для работы с taskwarrior-tui. +

+

DESCRIPTION

+

Входная точка для всех остальных скриптов проекта. +

+

NOTES

+
 Taskwarrior-tui передает в $@ uuid задач в виде строки с uuid разеделенные пробелами ("uuid1" "uuid2")
+
+ +
+ + + diff --git a/edit_project.sh b/edit_project.sh new file mode 100755 index 0000000..1e2e5bb --- /dev/null +++ b/edit_project.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +#****F* ./edit_project.sh +# NAME +# +# edit_project.sh - bash-скрипт для редактирования проекта в taskwarrior-tui. +#****** + +source "$LIB_DIR/edit.sh" + +declare task +declare tags +declare project + +task="$1" +project=$(getNameProject "$task") +tags=$(getTags "$task") + +if [[ "$project" == "" ]]; then + notify "msg-error" "Выбрана задача без проекта. Выход..." + exit 1 +elif [[ "$tags" =~ "someday" ]]; then + notify "msg-error" "Задача содержит тег #someday. Выход..." + exit 1 +fi + +getIdsTask "$task" +editStageProject "$task" +deleteProject "$task" +recreateProject diff --git a/jtx.sh b/jtx.sh new file mode 100755 index 0000000..1dcc19b --- /dev/null +++ b/jtx.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +#****F* ./jtx.sh +# NAME +# +# jtx.sh - bash-скрипт для работы с мобильным приложением jtxBoard. +#****** + +source "$HOME/bin/taskwarrior-tui-scripts/lib/global.sh" + +taskArr=($@) + +declare parentTaskUid +declare childIcsFile + +hasProject "$taskArr" + +for taskIndex in "${!taskArr[@]}"; do + todo new "$(task _get "${taskArr[$taskIndex]}".description)" + + parentTaskUid=$(ls "$MY_CAL" -tr --time="birth" | tail -n 1 | sed 's/\(.*\)\.ics/\1/') + + annotationNum=1 + while true; do + + declare task + + task=$(task _get "${taskArr[$taskIndex]}".annotations."$annotationNum".description) + + if [[ "$task" = "" ]]; then + break + else + todo new "$task" + + childIcsFile=$(ls "$MY_CAL" -tr --time="birth" | tail -n 1) + sed -i "/END:VTODO/i RELATED-TO;RELTYPE=PARENT:$parentTaskUid" "$MY_CAL/$childIcsFile" + + ((annotationNum++)) + fi + + done + + task rc.bulk=0 rc.confirmation=off delete "${taskArr[$taskIndex]}" +done + +vdirsyncer sync diff --git a/lib/edit.sh b/lib/edit.sh new file mode 100755 index 0000000..be271aa --- /dev/null +++ b/lib/edit.sh @@ -0,0 +1,107 @@ +#!/usr/bin/env bash + +#****F* lib/global.sh +# NAME +# +# global.sh - общие функции для всех скриптов. +# +# USES +# +# - environment.sh +#****** + +function getIdsTask() { + local nameProject + + nameProject=$(getNameProject "$1") + + readarray -t idsTaskProject < <(task project:"$nameProject" +current _ids) + printf '%s\n' "${idsTaskProject[@]}" +} + +function getFileHash() { + sha256sum "$1" | awk '{print $1}' +} + +function checkFilesHash() { + local originalHash + local currentHash + + originalHash=$(getFileHash "/tmp/tskw.edit.bak") + currentHash=$(getFileHash "/tmp/tskw.edit") + + if [[ "$originalHash" != "$currentHash" ]]; then + readarray -t taskStages < <(grep -v "^#" /tmp/tskw.edit + fi + + if [[ "${#tasksProject[@]}" -eq 0 ]]; then + + echo "# Проект без этапов. Эта строка будет проигнорирована." >>/tmp/tskw.edit + + backupStages + editStages + checkFilesHash + + return 0 + fi + + for taskID in "${tasksProject[@]}"; do + local uuid + uuid=$(task _get "$taskID".uuid) + + task _get "$uuid".description >>/tmp/tskw.edit + done + + backupStages + editStages + checkFilesHash +} + +function deleteProject() { + local idsTaskProject + local nameProject + + idsTaskProject=$(getIdsTask "$1") + nameProject=$(getNameProject "$1") + + if [[ "${#idsTaskProject[@]}" -eq 0 ]]; then + return + else + task rc.bulk=0 rc.confirmation=off project:"$nameProject" -COMPLETED -DELETED +current delete + fi +} + +function recreateProject() { + for taskIndex in "${!taskStages[@]}"; do + if [[ "$taskIndex" -eq 0 ]]; then + task add "${taskStages[$taskIndex]}" project:"$nameProject" order:$(("$taskIndex" + 2 - 1)) +current + else + task add "${taskStages[$taskIndex]}" project:"$nameProject" depends:"$uuidNewTask" order:$(("$taskIndex" + 2 - 1)) +current + fi + + local uuidNewTask + uuidNewTask=$(getLatestTaskUuid) + done +} diff --git a/lib/environment.sh b/lib/environment.sh new file mode 100755 index 0000000..00f69e7 --- /dev/null +++ b/lib/environment.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2016 + +#****F* lib/environment.sh +# NAME +# +# environment.sh - файл c основными константами и переменными. +# +# USED BY +# +# - edit_project.sh +# - jtx.sh +# - someday.sh +# - project.sh +# - start_stop.sh +#****** + +# Global +# +#****d* environment.sh/ROOT_DIR +# NAME +# +# ROOT_DIR - корень проекта. +#****** +export ROOT_DIR="$HOME/bin/taskwarrior-tui-scripts" + +#****d* environment.sh/LIB_DIR +# NAME +# +# LIB_DIR - папка с вспомогательными функциями. +#****** +export LIB_DIR="$ROOT_DIR/lib" + +#****d* environment.sh/MY_CAL +# NAME +# +# MY_CAL - папка с ics файлами календаря my_cal. +# +# NOTES +# +# https://baikal.bluig.xyz/dav.php/calendars/me/my_cal/ +#****** +export MY_CAL="$XDG_DATA_HOME/.calendars/my_cal" diff --git a/lib/global.sh b/lib/global.sh new file mode 100755 index 0000000..58f8721 --- /dev/null +++ b/lib/global.sh @@ -0,0 +1,265 @@ +#!/usr/bin/env bash + +#****F* lib/global.sh +# NAME +# +# global.sh - общие функции для всех скриптов. +# +# USES +# +# - environment.sh +#****** + +#****f* global.sh/notify +# NAME +# +# notify - вывод сообщения через notify-send. +# +# ARGUMENTS +# +# category - категория уведомления. +# message - строка сообщения. +# +# USAGE +# +# notify +# +# EXAMPLE +# +# notify "msg-error" "Ошибка!" +# +# NOTES +# +# Категории уведомлений находятся в $HOME/.config/mako/category +# +# USES +# +# - global.sh +# - project.sh +# - edit.sh +# - someday.sh +# - start_stop.sh +# - edit_project.sh +#****** +function notify() { + notify-send -t 3000 -a "taskwarrior" -c "$1" "$2" +} + +#****f* global.sh/getLatestTaskId +# NAME +# +# getLatestTaskId - возвращает id задачи. +# +# DESCRIPTION +# +# Возвращает id задачи с тегом +LATEST, которая является самой последней из добавленных. +# +# USES +# +# - project.sh +# +# NOTES +# +# https://taskwarrior.org/docs/tags/ +# +# RETURN VALUE +# +# return {string} - Id задачи +#****** +function getLatestTaskId() { + task +LATEST _id +} + +#****f* global.sh/getLatestTaskUuid +# NAME +# +# getLatestTaskUuid - возвращает id задачи. +# +# DESCRIPTION +# +# Возвращает uuid задачи с тегом +LATEST, которая является самой последней из добавленных. +# +# USES +# +# - project.sh +# +# NOTES +# +# https://taskwarrior.org/docs/tags/ +# +# RETURN VALUE +# +# return {string} - Uuid задачи +#****** +function getLatestTaskUuid() { + task +LATEST _uuid +} + +#****f* global.sh/getTags +# NAME +# +# getTags - возвращает массив тегов задачи. +# +# ARGUMENTS +# +# id | uuid - id или uuid задачи. +# +# USAGE +# +# getTags +# +# USES +# +# - project.sh +# - someday.sh +# - edit_project.sh +# +# RETURN VALUE +# +# return {Array} - Массив тегов +#****** +function getTags() { + task "$1" export | jq -r '.[].tags? | .[]?' +} + +#****f* global.sh/getNameProject +# NAME +# +# getNameProject - возвращает название проекта задачи. +# +# ARGUMENTS +# +# id | uuid - id или uuid задачи. +# +# USAGE +# +# getNameProject +# +# USES +# +# - edit.sh +# +# RETURN VALUE +# +# return {String} - Uuid задачи +#****** +function getNameProject() { + task "$1" _project +} + +#****f* global.sh/getAnnotationCount +# NAME +# +# getAnnotationCount - возвращает длину массива аннотаций задачи. +# +# ARGUMENTS +# +# id | uuid - id или uuid задачи. +# +# USAGE +# +# getAnnotationCount +# +# USES +# +# - project.sh +# +# RETURN VALUE +# +# return {String} - Количество аннотаций +#****** +function getAnnotationCount() { + task "$1" export | jq -r '.[] | .annotations | length' +} + +#****f* global.sh/checkExistingProject +# NAME +# +# checkExistingProject - проверка на наличие существующего проекта. +# +# ARGUMENTS +# +# id | uuid - id или uuid задачи. +# +# USAGE +# +# checkExistingProject +# +# USES +# +# - project.sh +#****** +function checkExistingProject() { + local task + local nameNewProject + + task="$1" + nameNewProject=$(task _get "$task".description) + readarray -t listExistingProjects < <(task _project | grep "$nameNewProject") + + if [[ "${#listExistingProjects[@]}" -ge 1 ]]; then + notify "msg-error" "Проект с таким названием уже существует. Выход..." + exit 1 + fi +} + +#****f* global.sh/hasProject +# NAME +# +# hasProject - проверка на наличие проекта у задачи. +# +# ARGUMENTS +# +# id | uuid - id или uuid задачи. +# +# USAGE +# +# hasProject +# +# USES +# +# - project.sh +#****** +function hasProject() { + local task + local hasProject + + task="$1" + + hasProject=$(task "$task" export | jq -r '.[] | .project') + + if [[ ! "$hasProject" == "null" ]]; then + clear + notify "msg-error" "Одна из выбранных задач имеет проект, выход..." + exit 1 + fi +} + +#****f* global.sh/denotateAllAnnotations +# NAME +# +# denotateAllAnnotations - удаление всех аннотаций у задачи. +# +# ARGUMENTS +# +# id | uuid - id или uuid задачи. +# +# USAGE +# +# denotateAllAnnotations +# +# USES +# +# - project.sh +#****** +function denotateAllAnnotations() { + local task + local countAnnotations + + task="$1" + countAnnotations=$(getAnnotationCount "$task") + + for ((i = 0; i < countAnnotations; i++)); do + task "$task" denotate + done +} 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 +} diff --git a/robodoc.rc b/robodoc.rc new file mode 100644 index 0000000..4c49abb --- /dev/null +++ b/robodoc.rc @@ -0,0 +1,49 @@ +# docs: https://rfsber.home.xs4all.nl/Robo/pages/robodoc-49942-user-manual.html#customizingitems +items: + NAME + DESCRIPTION + ARGUMENTS + USAGE + OUTPUTS + RETURN VALUE + NOTES + BUGS + EXAMPLE + SEE ALSO + USES + USED BY +item order: + NAME + DESCRIPTION + ARGUMENTS + USAGE + RETURN VALUE + OUTPUTS + EXAMPLE + USES + USED BY + NOTES + BUGS + SEE ALSO +source items: + USAGE + ARGUMENTS + EXAMPLE + RETURN VALUE +preformatted items: + SEE ALSO + NOTES +options: + --src . + --doc ./docs + --html + --charset UTF-8 + --index + --nopre + --sections + --multidoc + --tabsize 2 +headertypes: + D "Directories" robo_dirs 1 + F "Files" robo_files 2 +ignore files: diff --git a/tskw.sh b/tskw.sh new file mode 100755 index 0000000..7022868 --- /dev/null +++ b/tskw.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +set -e + +#****h* taskwarrior-tui-scripts/tskw.sh +# NAME +# +# tskw.sh - основной выполняемый скрипт для работы с taskwarrior-tui. +# +# DESCRIPTION +# +# Входная точка для всех остальных скриптов проекта. +# +# NOTES +# +# Taskwarrior-tui передает в $@ uuid задач в виде строки с uuid разеделенные пробелами ("uuid1" "uuid2") +#****** + +#****D* taskwarrior-tui-scripts/lib +# NAME +# +# lib - папка с вспомогательными функциями. +#****** + +source "$HOME/bin/taskwarrior-tui-scripts/lib/environment.sh" +source "$LIB_DIR/global.sh" + +declare action +declare task + +action="$1" +shift + +task="$1" + +if [[ "$#" -gt 1 ]]; then + notify "msg-error" "Выбрано больше одной задачи. Выход..." + exit 1 +fi + +case "$action" in +"project") + source "$LIB_DIR/project.sh" + + taskCheck "$task" + taskProj "$task" + ;; +"edit_project") + "$ROOT_DIR/edit_project.sh" "$task" + ;; +"jtx") + "$ROOT_DIR/jtx.sh" "$task" + ;; +*) + notify "msg-error" "Неизвестное действие. Выход..." + exit 1 + ;; +esac -- cgit