mirror of
https://github.com/simonw/datasette.git
synced 2026-09-02 22:54:08 +02:00
Merge d1fa64f5b0 into 0337fba234
This commit is contained in:
commit
5baa2eb47a
2 changed files with 29 additions and 2 deletions
|
|
@ -122,8 +122,29 @@ def sqlite_extensions(fn):
|
|||
return wrapped
|
||||
|
||||
|
||||
def _print_version(ctx, param, value):
|
||||
if not value or ctx.resilient_parsing:
|
||||
return
|
||||
sqlite_version = (
|
||||
sqlite3.connect(":memory:").execute("select sqlite_version()").fetchone()[0]
|
||||
)
|
||||
click.echo(
|
||||
"{}, version {} (SQLite {})".format(
|
||||
ctx.find_root().info_name, __version__, sqlite_version
|
||||
)
|
||||
)
|
||||
ctx.exit()
|
||||
|
||||
|
||||
@click.group(cls=DefaultGroup, default="serve", default_if_no_args=True)
|
||||
@click.version_option(version=__version__)
|
||||
@click.option(
|
||||
"--version",
|
||||
is_flag=True,
|
||||
expose_value=False,
|
||||
is_eager=True,
|
||||
callback=_print_version,
|
||||
help="Show the version and exit.",
|
||||
)
|
||||
def cli():
|
||||
"""
|
||||
Datasette is an open source multi-tool for exploring and publishing data
|
||||
|
|
|
|||
|
|
@ -231,7 +231,13 @@ def test_uninstall(run_module):
|
|||
def test_version():
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, ["--version"])
|
||||
assert result.output == f"cli, version {__version__}\n"
|
||||
expected_sqlite_version = (
|
||||
sqlite3.connect(":memory:").execute("select sqlite_version()").fetchone()[0]
|
||||
)
|
||||
assert (
|
||||
result.output
|
||||
== f"cli, version {__version__} (SQLite {expected_sqlite_version})\n"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("invalid_port", ["-1", "0.5", "dog", "65536"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue