Added extra metadata options to publish and package commands

You can now run these commands like so:

    datasette now publish mydb.db \
        --title="My Title" \
        --source="Source" \
        --source_url="http://www.example.com/" \
        --license="CC0" \
        --license_url="https://creativecommons.org/publicdomain/zero/1.0/"

This will write those values into the metadata.json that is packaged with the
app. If you also pass --metadata= that file will be updated with the extra
values before being written into the Docker image.

Closes #92
This commit is contained in:
Simon Willison 2017-11-14 21:02:11 -08:00
commit 7fe1e8b482
3 changed files with 36 additions and 8 deletions

View file

@ -38,7 +38,12 @@ def build(files, inspect_file):
)
@click.option('--extra-options', help='Extra options to pass to datasette serve')
@click.option('--force', is_flag=True, help='Pass --force option to now')
def publish(publisher, files, name, metadata, extra_options, force):
@click.option('--title', help='Title for metadata')
@click.option('--license', help='License label for metadata')
@click.option('--license_url', help='License URL for metadata')
@click.option('--source', help='Source label for metadata')
@click.option('--source_url', help='Source URL for metadata')
def publish(publisher, files, name, metadata, extra_options, force, **extra_metadata):
"""
Publish specified SQLite database files to the internet along with a datasette API.
@ -58,7 +63,7 @@ def publish(publisher, files, name, metadata, extra_options, force):
click.echo('Follow the instructions at https://zeit.co/now#whats-now', err=True)
sys.exit(1)
with temporary_docker_directory(files, name, metadata, extra_options):
with temporary_docker_directory(files, name, metadata, extra_options, extra_metadata):
if force:
call(['now', '--force'])
else:
@ -76,7 +81,12 @@ def publish(publisher, files, name, metadata, extra_options, force):
help='Path to JSON file containing metadata to publish'
)
@click.option('--extra-options', help='Extra options to pass to datasette serve')
def package(files, tag, metadata, extra_options):
@click.option('--title', help='Title for metadata')
@click.option('--license', help='License label for metadata')
@click.option('--license_url', help='License URL for metadata')
@click.option('--source', help='Source label for metadata')
@click.option('--source_url', help='Source URL for metadata')
def package(files, tag, metadata, extra_options, **extra_metadata):
"Package specified SQLite files into a new datasette Docker container"
if not shutil.which('docker'):
click.secho(
@ -87,7 +97,7 @@ def package(files, tag, metadata, extra_options):
err=True,
)
sys.exit(1)
with temporary_docker_directory(files, 'datasette', metadata, extra_options):
with temporary_docker_directory(files, 'datasette', metadata, extra_options, extra_metadata):
args = ['docker', 'build']
if tag:
args.append('-t')