Skip to content

Commit

Permalink
cmdrefgen to generate command ref
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenet committed Feb 16, 2015
1 parent 01feeac commit 380068e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions bin/gencmdref
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python

import os
import sys
import datetime
import subprocess

from subprocess import check_output

def run(cmd):
return check_output(cmd)

def main():
lines = [l.strip() for l in sys.stdin]

print '# ipfs command reference'
print ''
print 'generated on', datetime.datetime.now()
print ''
for line in lines:
print '- [%s](#%s)' % (line, line.replace(' ', '-'))
print ''

for line in lines:
print '## %s' % line
print ''
print '```'
print run((line + ' --help').split(' ')).strip()
print '```'
print ''

if __name__ == '__main__':
if '-h' in sys.argv or '--help' in sys.argv:
print 'usage: ipfs commands | %s >cmdref.md' % sys.argv[0]
print 'outputs all commands with --help to a markdown file'
exit(0)

main()

0 comments on commit 380068e

Please sign in to comment.