kopia lustrzana https://github.com/simonw/datasette
29 wiersze
817 B
Python
29 wiersze
817 B
Python
import click
|
|
from click_default_group import DefaultGroup
|
|
from .app import app_factory, ensure_build_metadata
|
|
|
|
|
|
@click.group(cls=DefaultGroup, default='serve', default_if_no_args=True)
|
|
def cli():
|
|
"""
|
|
Immutabase!
|
|
"""
|
|
|
|
|
|
@cli.command()
|
|
@click.argument('files', type=click.Path(exists=True), nargs=-1)
|
|
def build(files):
|
|
ensure_build_metadata(files, True)
|
|
|
|
|
|
@cli.command()
|
|
@click.argument('files', type=click.Path(exists=True), nargs=-1)
|
|
@click.option('-h', '--host', default='0.0.0.0')
|
|
@click.option('-p', '--port', default=8001)
|
|
@click.option('--debug', is_flag=True)
|
|
def serve(files, host, port, debug):
|
|
"""Serve up specified database files with a web UI"""
|
|
click.echo('Serve! files={} on port {}'.format(files, port))
|
|
app = app_factory(files)
|
|
app.run(host=host, port=port, debug=debug)
|