You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
619 B

  1. import io
  2. import sys
  3. import re
  4. README_FILE = 'README.md'
  5. helptext = sys.stdin.read()
  6. if isinstance(helptext, bytes):
  7. helptext = helptext.decode('utf-8')
  8. with io.open(README_FILE, encoding='utf-8') as f:
  9. oldreadme = f.read()
  10. header = oldreadme[:oldreadme.index('# OPTIONS')]
  11. footer = oldreadme[oldreadme.index('# CONFIGURATION'):]
  12. options = helptext[helptext.index(' General Options:') + 19:]
  13. options = re.sub(r'(?m)^ (\w.+)$', r'## \1', options)
  14. options = '# OPTIONS\n' + options + '\n'
  15. with io.open(README_FILE, 'w', encoding='utf-8') as f:
  16. f.write(header)
  17. f.write(options)
  18. f.write(footer)