| 1 | #!/usr/bin/env python |
| 2 | |
| 3 | import os |
| 4 | import sys |
| 5 | import datetime |
| 6 | |
| 7 | from subprocess import check_output |
| 8 | |
| 9 | def run(cmd): |
| 10 | return check_output(cmd) |
| 11 | |
| 12 | def main(): |
| 13 | lines = [l.strip() for l in sys.stdin] |
| 14 | |
| 15 | print '# ipfs command reference' |
| 16 | print '' |
| 17 | print 'generated on', datetime.datetime.now() |
| 18 | print '' |
| 19 | for line in lines: |
| 20 | print '- [%s](#%s)' % (line, line.replace(' ', '-')) |
| 21 | print '' |
| 22 | |
| 23 | for line in lines: |
| 24 | print '## %s' % line |
| 25 | print '' |
| 26 | print '```' |
| 27 | print run((line + ' --help').split(' ')).strip() |
| 28 | print '```' |
| 29 | print '' |
| 30 | |
| 31 | if __name__ == '__main__': |
| 32 | if '-h' in sys.argv or '--help' in sys.argv: |
| 33 | print 'usage: ipfs commands | %s >cmdref.md' % sys.argv[0] |
| 34 | print 'outputs all commands with --help to a markdown file' |
| 35 | exit(0) |
| 36 | |
| 37 | main() |