2018-04-07 04:17:49 +02:00
|
|
|
#!/usr/bin/env python3
|
2018-07-21 00:16:24 +02:00
|
|
|
import os
|
2018-04-07 04:17:49 +02:00
|
|
|
import sys
|
|
|
|
import click
|
|
|
|
import ciclostile
|
|
|
|
|
2018-07-21 01:38:42 +02:00
|
|
|
# from ciclostile.web import app as webapp
|
2018-04-24 18:09:02 +02:00
|
|
|
|
2018-04-07 04:17:49 +02:00
|
|
|
|
|
|
|
@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)
|
|
|
|
|
|
|
|
|
2018-07-21 01:38:42 +02:00
|
|
|
@cli.command()
|
|
|
|
@click.argument("input_dir", default=os.getcwd(),
|
|
|
|
type=click.Path(exists=True,
|
|
|
|
file_okay=False))
|
|
|
|
def compile_all(input_dir):
|
|
|
|
ciclostile.compile_all(input_dir)
|
|
|
|
|
|
|
|
|
2018-04-24 18:09:02 +02:00
|
|
|
@cli.command()
|
|
|
|
@click.option("-p", "--port", type=int, default=12345)
|
2018-07-21 01:38:42 +02:00
|
|
|
@click.argument("input_dir", default=os.getcwd(),
|
|
|
|
type=click.Path(exists=True,
|
|
|
|
file_okay=False))
|
2018-07-21 00:16:24 +02:00
|
|
|
def app(port, input_dir):
|
|
|
|
print({'port': port,
|
|
|
|
'input': input_dir})
|
|
|
|
# webapp.run(port=port)
|
2018-04-24 18:09:02 +02:00
|
|
|
|
|
|
|
|
2018-04-07 04:17:49 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
cli()
|