1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-26 23:53:19 +08:00

cmdrefgen to generate command ref

This commit is contained in:
Juan Batiz-Benet
2015-02-16 13:53:07 -08:00
parent 01feeac1bb
commit 380068e6ff

38
bin/gencmdref Executable file
View File

@ -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()