Skip to content

Commit 70e2151

Browse files
authored
Merge pull request #194 from dbcli/use-setup-scm
Use setup scm
2 parents ca7bce5 + 79adc64 commit 70e2151

4 files changed

Lines changed: 20 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.13.1 - 2024-11-24
2+
3+
### Internal
4+
5+
* Read the version from the git tag using setuptools-scm
6+
17
## 1.13.0 - 2024-11-23
28

39
### Features

litecli/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
__version__ = "1.13.0"
1+
import importlib.metadata
2+
3+
__version__ = importlib.metadata.version("litecli")

litecli/main.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,15 @@ def get_last_query(self):
825825
return self.query_history[-1][0] if self.query_history else None
826826

827827

828+
def version_callback(ctx: click.Context, param: click.Parameter, value: bool) -> None:
829+
if not value or ctx.resilient_parsing:
830+
return
831+
click.echo(f"Version: {__version__}", color=ctx.color)
832+
ctx.exit()
833+
834+
828835
@click.command()
829-
@click.option("-V", "--version", is_flag=True, help="Output litecli's version.")
836+
@click.option("-V", "--version", callback=version_callback, expose_value=False, is_eager=True, is_flag=True, help="Show version.")
830837
@click.option("-D", "--database", "dbname", help="Database to use.")
831838
@click.option(
832839
"-R",
@@ -859,7 +866,6 @@ def get_last_query(self):
859866
def cli(
860867
database,
861868
dbname,
862-
version,
863869
prompt,
864870
logfile,
865871
auto_vertical_output,
@@ -876,11 +882,6 @@ def cli(
876882
- litecli lite_database
877883
878884
"""
879-
880-
if version:
881-
print("Version:", __version__)
882-
sys.exit(0)
883-
884885
litecli = LiteCli(
885886
prompt=prompt,
886887
logfile=logfile,

pyproject.toml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ dynamic = ["version"]
44
description = "CLI for SQLite Databases with auto-completion and syntax highlighting."
55
readme = "README.md"
66
requires-python = ">=3.7"
7-
license = {text = "BSD"}
8-
authors = [
9-
{name = "dbcli", email = "litecli-users@googlegroups.com"}
10-
]
7+
license = { text = "BSD" }
8+
authors = [{ name = "dbcli", email = "litecli-users@googlegroups.com" }]
119
urls = { "homepage" = "https://github.com/dbcli/litecli" }
1210
dependencies = [
1311
"cli-helpers[styles]>=2.2.1",
@@ -19,7 +17,7 @@ dependencies = [
1917
]
2018

2119
[build-system]
22-
requires = ["setuptools >= 61.0"]
20+
requires = ["setuptools>=64.0", "setuptools-scm>=8"]
2321
build-backend = "setuptools.build_meta"
2422

2523
[project.scripts]
@@ -42,8 +40,5 @@ exclude = ["screenshots", "tests*"]
4240
[tool.setuptools.package-data]
4341
litecli = ["liteclirc", "AUTHORS"]
4442

45-
[tool.setuptools.dynamic]
46-
version = {attr = "litecli.__version__"}
47-
4843
[tool.ruff]
4944
line-length = 140

0 commit comments

Comments
 (0)