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.

26 lines
660 B

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