Last active
August 29, 2015 14:01
-
-
Save qmega/97cbda7fa34f068efbe9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from sys import stdin | |
lines = stdin.readlines() | |
for opt, desc in (line.strip().split(None, 1) for line in lines[2:-2]): | |
has_args = 'Flag' not in desc and 'Print' not in desc | |
line = '' | |
if has_args: | |
line += '=' | |
#line += '[FIXME]' | |
if has_args: | |
line += ':{}:'.format(desc.replace(':', '\\:').replace("'", "'\\''")) | |
if 'Choices: ' in desc: | |
choices = desc.partition('Choices: ')[2].partition('(')[0].strip().split() | |
line += '(({}))'.format(' '.join(choices)) | |
if has_args or 'Print' in desc or opt.startswith('--no-'): | |
print("'{}{}' \\".format(opt, line)) | |
else: | |
negated_opt = ''.join((opt[:2], 'no-', opt[2:])) | |
print("'({}){}{}' \\".format(negated_opt, opt, line)) | |
print("'({}){}{}' \\".format(opt, negated_opt, line)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment