You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB

#!/usr/bin/env python3
import os
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("input_dir", default=os.getcwd(), type=click.Path(exists=True,
file_okay=False))
def app(port, input_dir):
print({'port': port,
'input': input_dir})
# webapp.run(port=port)
if __name__ == "__main__":
cli()