Mercurial > jouvence
comparison scripts/fontaine @ 10:2cea36073188
Move core CLI tool code into the package.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 04 Jan 2017 08:46:27 -0800 |
parents | a5488b474c6b |
children |
comparison
equal
deleted
inserted
replaced
9:a5488b474c6b | 10:2cea36073188 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 import os.path | 2 import os.path |
3 import sys | 3 import sys |
4 import argparse | |
5 | 4 |
6 | 5 |
7 sys.path.append(os.path.dirname(os.path.dirname(__file__))) | 6 sys.path.append(os.path.dirname(os.path.dirname(__file__))) |
8 | 7 |
9 | 8 |
10 def main(): | |
11 parser = argparse.ArgumentParser( | |
12 description='Fontaine command line utility') | |
13 parser.add_argument('script') | |
14 parser.add_argument('out_file', nargs='?') | |
15 args = parser.parse_args() | |
16 | |
17 from fontaine.parser import FontaineParser | |
18 p = FontaineParser() | |
19 doc = p.parse(args.script) | |
20 | |
21 if not args.out_file: | |
22 from fontaine.console import ConsoleDocumentRenderer | |
23 rdr = ConsoleDocumentRenderer() | |
24 rdr.render_doc(doc, sys.stdout) | |
25 else: | |
26 from fontaine.html import HtmlDocumentRenderer | |
27 rdr = HtmlDocumentRenderer() | |
28 with open(args.out_file, 'w') as fp: | |
29 rdr.render_doc(doc, fp) | |
30 | |
31 if __name__ == '__main__': | 9 if __name__ == '__main__': |
10 from fontaine.cli import main | |
32 main() | 11 main() |