From 380068e6ff161ef50c40b963f065aa40d5cbb8d0 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Mon, 16 Feb 2015 13:53:07 -0800 Subject: [PATCH] cmdrefgen to generate command ref --- bin/gencmdref | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 bin/gencmdref diff --git a/bin/gencmdref b/bin/gencmdref new file mode 100755 index 000000000..e8a9ea62e --- /dev/null +++ b/bin/gencmdref @@ -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()