]>
Commit | Line | Data |
---|---|---|
1e91866f | 1 | import io |
4bb028f4 FV |
2 | import sys |
3 | import re | |
4 | ||
682407f2 | 5 | README_FILE = 'README.md' |
4bb028f4 FV |
6 | helptext = sys.stdin.read() |
7 | ||
49f2bf76 PH |
8 | if isinstance(helptext, bytes): |
9 | helptext = helptext.decode('utf-8') | |
10 | ||
1e91866f | 11 | with io.open(README_FILE, encoding='utf-8') as f: |
682407f2 | 12 | oldreadme = f.read() |
4bb028f4 FV |
13 | |
14 | header = oldreadme[:oldreadme.index('# OPTIONS')] | |
15 | footer = oldreadme[oldreadme.index('# CONFIGURATION'):] | |
16 | ||
49f2bf76 | 17 | options = helptext[helptext.index(' General Options:') + 19:] |
d19bb9c0 | 18 | options = re.sub(r'(?m)^ (\w.+)$', r'## \1', options) |
4bb028f4 FV |
19 | options = '# OPTIONS\n' + options + '\n' |
20 | ||
1e91866f | 21 | with io.open(README_FILE, 'w', encoding='utf-8') as f: |
682407f2 | 22 | f.write(header) |
23 | f.write(options) | |
24 | f.write(footer) |