summaryrefslogtreecommitdiffhomepage
path: root/support
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2016-01-07 08:11:00 +0100
committerMatthias Braun <matze@braunis.de>2016-01-07 08:16:52 +0100
commit38cd99af5cd249550ca49b17db9f8b2ef8b6dfe8 (patch)
treec800f3542b2f9ea174dde98a852d161092f6e968 /support
parentd98ef4dca0d6082b93eac9ceda275e7503bdcf10 (diff)
Add helper script to check if all options have help texts
Diffstat (limited to 'support')
-rwxr-xr-xsupport/check_options.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/support/check_options.py b/support/check_options.py
new file mode 100755
index 0000000..bd5137a
--- /dev/null
+++ b/support/check_options.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+import re
+
+# Search for defined options
+optionsfile = open("src/driver/options.c").readlines() + open("src/main.c").readlines()
+functions = [ 'simple_arg', 'prefix_arg', 'spaced_arg', 'equals_arg',
+ 'f_yesno_arg' ]
+regex = '(?P<function>' + "|".join(functions) + ')'
+regex += '\s*\(\s*"(?P<option>[^"]+)"'
+parsed_options = []
+for line in optionsfile:
+ for m in re.finditer(regex, line):
+ option = m.group('option')
+ function = m.group('function')
+ if function != 'f_yesno_arg':
+ option = '-' + option
+ parsed_options.append(option)
+ # accept_prefix() takes s as first argument
+ for m in re.finditer('accept_prefix\s*\([^,]*,\s*"(?P<option>[^"]+)', line):
+ option = m.group('option')
+ parsed_options.append(option)
+
+# Search for help strings
+helpfile = open("src/driver/help.c")
+functions = [ 'help_simple', 'help_prefix', 'help_spaced', 'help_equals',
+ 'help_aprefix' ]
+regex = '(?P<function>' + "|".join(functions) + ')'
+regex += '\s*\(\s*"(?P<option>[^"]+)"'
+help_options = []
+for line in helpfile:
+ for m in re.finditer(regex, line):
+ 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"
+
+print "Help for nonexistant option:",
+for x in help_options:
+ if x not in parsed_options:
+ print x,
+print ""