Update TODO
[sloppygui.git] / tools / src-entries.sh
blobe6f7c618079be5d868fc8a889588b115aa59966c
1 #!/bin/sh
3 # Print TODO, FIXME, HACK and NOTE entries from source code files.
5 # Default settings
6 print_todos="yes"
7 print_fixmes="yes"
8 print_hacks="yes"
9 print_notes="yes"
11 print_line_numbers="yes"
12 print_file_name="yes"
14 print_entries()
16 for file in `find . \( ! -regex '.*/\..*' -a -name "*.cpp" -o -name "*.h" \) -type f`
18 grep -n -E '^\W*// (TODO|FIXME|HACK|NOTE):' $file | while read entry
20 local line_num=`echo "$entry" | cut -f 1 -d :`
21 local entry_type=`echo "$entry" | cut -f 2 -d : | sed -e 's/^\W*//g'`
22 local entry_text="`echo $entry | cut -f 3 -d : | sed -e 's/^\W*//g'`"
24 # Should we print this type of entry?
25 local print_this_type="yes"
27 case $entry_type in
28 TODO )
29 if [ $print_todos = "no" ]; then
30 print_this_type="no"
34 FIXME )
35 if [ $print_fixmes = "no" ]; then
36 print_this_type="no"
40 HACK )
41 if [ $print_hacks = "no" ]; then
42 print_this_type="no"
46 NOTE )
47 if [ $print_notes = "no" ]; then
48 print_this_type="no"
51 esac
53 if [ $print_this_type = "yes" ]
54 then
55 if [ $print_file_name = "no" ]
56 then
57 echo "$entry_type: $entry_text"
58 else
59 if [ $print_line_numbers = "no" ]
60 then
61 echo "$file: $entry_type: $entry_text"
62 else
63 echo "$file:$line_num: $entry_type: $entry_text"
67 done
68 done
71 print_usage()
73 echo "Usage: src-entries.sh [options]"
74 echo ""
75 echo "Print TODO, FIXME, HACK and NOTE entries from source code files. All"
76 echo "entries are printed by default with the file name and line number."
77 echo ""
78 echo "The entries must be in format:"
79 echo ""
80 echo " <whitespace>// [TODO|FIXME|HACK|NOTE]: <text>"
81 echo ""
82 echo "Only one entry per line (text included) is currently supported."
83 echo ""
84 echo "Options:"
85 echo ""
86 echo " --no-file-name don't print the file name where the entry came from"
87 echo " --no-line-number don't print the line number where the entry came from"
88 echo " --no-todos don't print TODO entries"
89 echo " --no-fixmes don't print FIXME entries"
90 echo " --no-hacks don't print HACK entries"
91 echo " --no-notes don't print NOTE entries"
92 echo ""
93 exit 0
96 while [ $# -ge 1 ]
98 case $1 in
99 --no-file-name )
100 print_file_name="no"
102 # Disable printing line number too as it's pretty much useless
103 # without the file name
104 print_line_numbers="no"
106 --no-line-number )
107 print_line_numbers="no"
109 --no-todos )
110 print_todos="no"
112 --no-fixmes )
113 print_fixmes="no"
115 --no-hacks )
116 print_hacks="no"
118 --no-notes )
119 print_notes="no"
122 print_usage
124 esac
126 shift
127 done
129 print_entries
131 exit 0