summaryrefslogtreecommitdiffhomepage
path: root/support
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2016-01-15 08:31:15 +0100
committerMatthias Braun <matze@braunis.de>2016-01-15 09:12:18 +0100
commit2e7ae33f14b6d04fe1cc74ba1b48e6c878fe9aa0 (patch)
tree88701040e78828d8ec4be11d44797c2ea0cea46c /support
parent48533d9341bb662722798694583fdd9582a61bd6 (diff)
check_options: Cleanup output exit with error on problems
Diffstat (limited to 'support')
-rwxr-xr-xsupport/check_options.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/support/check_options.py b/support/check_options.py
index bd5137a..8c2184c 100755
--- a/support/check_options.py
+++ b/support/check_options.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
import re
+import sys
+import collections
# Search for defined options
optionsfile = open("src/driver/options.c").readlines() + open("src/main.c").readlines()
@@ -23,7 +25,7 @@ for line in optionsfile:
# Search for help strings
helpfile = open("src/driver/help.c")
functions = [ 'help_simple', 'help_prefix', 'help_spaced', 'help_equals',
- 'help_aprefix' ]
+ 'help_aprefix', 'help_f_yesno' ]
regex = '(?P<function>' + "|".join(functions) + ')'
regex += '\s*\(\s*"(?P<option>[^"]+)"'
help_options = []
@@ -32,14 +34,28 @@ for line in helpfile:
help_options.append(m.group('option'))
# See which options lack a help string
-print "Options lacking help:",
-for x in parsed_options:
- if x not in help_options:
- print x,
-print "\n"
+found_a_problem = False
-print "Help for nonexistant option:",
-for x in help_options:
- if x not in parsed_options:
+def print_list(prefix, l):
+ global found_a_problem
+ intro = False
+ for x in l:
+ if not intro:
+ print prefix,
+ intro = True
+ found_a_problem = True
print x,
-print ""
+ if intro:
+ print ""
+
+duplicates = [item for (item, count) in collections.Counter(help_options).items() if count > 1]
+print_list("Duplicate help:", duplicates)
+
+no_help = set(parsed_options) - set(help_options)
+print_list("Options lacking help:", no_help)
+
+no_option = set(help_options) - set(parsed_options)
+print_list("Help for nonexistant option:", no_option)
+
+if found_a_problem:
+ sys.exit(1)