summaryrefslogtreecommitdiffhomepage
path: root/tools/todo.sh
blob: 44c7929b84836219bbc972bd5eb92408fbcbceeb (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
# This file is dedicated to the public domain.

todo() {
	if [ $# = 0 ]; then
		printf "Active TODO list:\n\n"
		ls TODO/ | {
			while read _l; do
				printf "  * %s: " "$_l"
				head -n1 "TODO/$_l"
			done
		}
		return
	fi
	if [ $# != 1 ]; then
		echo "expected 0 or 1 argument(s)"
		return
	fi
	if [ -f "TODO/$1" ]; then
		printf "Active TODO item: "
		_f="TODO/$1"
	elif [ -f "TODO/.$1" ]; then
		printf "Inactive TODO item: "
		_f="TODO/.$1"
	else
		echo "TODO item not found: $1"
		return
	fi
	head -n1 "$_f"
	printf "\n"
	sed -n '/^====$/,$p' "$_f"
	printf "====\n\nMentions in project:\n"
	git grep -Fn "TODO($1)" || echo "<none>"
}

# vi: sw=4 ts=4 noet tw=80 cc=80