aboutsummaryrefslogtreecommitdiff
path: root/jtx.sh
blob: ff2fc2b178179a80398f4565ead004cb2f100648 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash

#****F* taskwarrior-tui-scripts/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