forked from unit/ciclostile
44 lines
1.1 KiB
Python
Executable File
44 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import sys
|
|
import click
|
|
import ciclostile
|
|
|
|
from ciclostile.web import app as webapp
|
|
|
|
|
|
@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)
|
|
|
|
|
|
@cli.command()
|
|
@click.option("-p", "--port", type=int, default=12345)
|
|
@click.argument("post_dir", default=".")
|
|
def app(port, post_dir):
|
|
webapp.run(port=port)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
cli()
|