-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdit-import
executable file
·77 lines (62 loc) · 1.55 KB
/
dit-import
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
# This script updates reduced in-tree dump of TODO.md file by importing its
# contents from dit and applying necessary formatting.
function process_item()
{
if [ "$first" == 0 ]; then
echo
fi
echo "## ${data[title]} ##"
echo
column -x -t -o ' | ' -s '|' <<-EOF | sed -e 's/^/| /' -e 's/|[^|]\+$/|/' \
-e '1{h;s/[^|]/-/g;x;G}'
ID | Status | Type | dummy
${data[_id]} | ${data[status]} | ${data[type]} | dummy
EOF
if [ "${data[status]}" = partial ]; then
echo '(partially done)'
fi
if [ -n "${data[comment]}" ]; then
echo
echo "${data[comment]}"
fi
first=0
}
function process_items()
{
declare -A data
first=1
while read -rd $'\0' line; do
if [ -z "$line" ]; then
process_item
unset data
declare -A data
continue
fi
key="${line%%=*}"
value="${line#*=}"
data[$key]="$value"
done
}
function list_component()
{
local title="$1"
shift
local out="$(dit .uncov export - \
status!=done status!=dismissed status!=fixed "$@" |
process_items)"
if [ -n "$out" ]; then
echo
echo "# $title #"
echo
echo "$out"
fi
}
function make_todo()
{
list_component 'Core' component==
list_component 'Vim Plugin' component==vim-plugin
list_component 'Web-UI' component==web-ui
}
dir="$(readlink -f "$(dirname "$0")")"
make_todo | tail +2 > "$dir/../TODO.md"