-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplanner2taskwarrior.sh
More file actions
executable file
·78 lines (71 loc) · 2.08 KB
/
planner2taskwarrior.sh
File metadata and controls
executable file
·78 lines (71 loc) · 2.08 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#
# Script to convert planner plans (tasks) into taskwarrior tasks
# Authors: Joshua James (joshua@cybercrimetech.com)
# License: GPLv3
# Version: 0.1
#
# Requirements: Planner, taskwarrior (tested with 2.5.1)
#
printUsage(){
echo "Usage: $0 [user] plannerXml"
echo " plannerXml: an XML file generated by planner"
exit 1
}
if [ ! -f "$1" ]; then
printUsage
exit 1
fi
# Check if task is complete (by name)
function checkComplete {
#echo "Checking complete: $1"
task complete "$1" &> /dev/null
return $?
}
# Check if task is in main list (by name)
function checkMain {
#echo "Checking main $1"
task list "$1" &> /dev/null
return $?
}
# Check if task is in waiting list (by name)
function checkWaiting {
#echo "Checking waiting $1"
task waiting "$1" &> /dev/null
return $?
}
projName=$(egrep "project name" $1 | awk -F'"' '{print $2}')
egrep "<task |predecessor-id" $1 | while read -r line ; do
if [[ $line != *"predecessor"* ]]; then # use to detect prior tasks *TODO*
name=$(echo $line | awk -F'"' '{print $4}')
id=$(echo $line | awk -F'"' '{print $2}')
wait=$(echo $line | awk -F'"' '{print $10}')
end=$(echo $line | awk -F'"' '{print $12}')
# Check if task has been completed. If yes - skip
checkComplete "$name"
if [ $? == 0 ]; then # is complete
continue
else
checkWaiting "$name"
tskWait=$?
checkMain "$name"
tskMain=$?
if [ $tskWait == 0 ]; then # is waiting - update
#echo "Waiting"
taskID=$(task waiting "$name" | grep -A2 "Age" | tail -n 1 | awk '{print $1}') > /dev/null
#echo "Task ID is $taskID"
task $taskID modify due:$end wait:$wait &> /dev/null
elif [ $tskMain == 0 ]; then # is in main - update
#echo "Main"
taskID=$(task list "$name" | grep -A2 "Age" | tail -n 1 | awk '{print $1}') > /dev/null
#echo "Task ID is $taskID"
task $taskID modify due:$end wait:$wait &> /dev/null
else
# Task does not exist yet. Create task.
# creates duplicates if the name has special characters
#echo "Create task"
task add project:"$projName" due:$end wait:$wait $name &> /dev/null
fi
fi
fi
done