Skip to content

Commit

Permalink
-c shortcut for --config - refs #2143, #2149
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Aug 23, 2023
1 parent 17ec309 commit 2ce7872
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions datasette/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ def uninstall(packages, yes):
)
@click.option("--memory", is_flag=True, help="Make /_memory database available")
@click.option(
"-c",
"--config",
type=click.File(mode="r"),
help="Path to JSON/YAML Datasette configuration file",
Expand Down
24 changes: 24 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,30 @@ def test_serve_create(tmpdir):
assert db_path.exists()


@pytest.mark.parametrize("argument", ("-c", "--config"))
@pytest.mark.parametrize("format_", ("json", "yaml"))
def test_serve_config(tmpdir, argument, format_):
config_path = tmpdir / "datasette.{}".format(format_)
config_path.write_text(
"settings:\n default_page_size: 5\n"
if format_ == "yaml"
else '{"settings": {"default_page_size": 5}}',
"utf-8",
)
runner = CliRunner()
result = runner.invoke(
cli,
[
argument,
str(config_path),
"--get",
"/-/settings.json",
],
)
assert result.exit_code == 0, result.output
assert json.loads(result.output)["default_page_size"] == 5


def test_serve_duplicate_database_names(tmpdir):
"'datasette db.db nested/db.db' should attach two databases, /db and /db_2"
runner = CliRunner()
Expand Down

0 comments on commit 2ce7872

Please sign in to comment.