forked from unit/ciclostile
35 lines
930 B
Python
35 lines
930 B
Python
|
#!/usr/bin/env python3
|
||
|
import sys
|
||
|
import click
|
||
|
import ciclostile
|
||
|
|
||
|
|
||
|
@click.group()
|
||
|
def cli():
|
||
|
pass
|
||
|
|
||
|
|
||
|
@cli.command()
|
||
|
@click.option('-t', '--template', type=click.File('r'))
|
||
|
@click.option('-o', '--output', type=click.File('w'), default=sys.stdout)
|
||
|
@click.argument('markdown', type=click.File('r'), default=sys.stdin)
|
||
|
def compile(template, output, markdown):
|
||
|
data = ciclostile.parse(markdown.read())
|
||
|
html = ciclostile.compile(template.read(), data)
|
||
|
output.write(html)
|
||
|
|
||
|
|
||
|
@cli.command()
|
||
|
@click.option('-t', '--template', type=click.File('r'))
|
||
|
@click.option('-o', '--output', type=click.File('w'), default=sys.stdout)
|
||
|
@click.argument('folder', type=click.Path(exists=True,
|
||
|
file_okay=False))
|
||
|
def index(template, output, folder):
|
||
|
data = ciclostile.index(folder)
|
||
|
html = ciclostile.compile(template.read(), data)
|
||
|
output.write(html)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
cli()
|