-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |