Skip to content

Commit

Permalink
Merge pull request #194 from dbcli/use-setup-scm
Browse files Browse the repository at this point in the history
Use setup scm
  • Loading branch information
amjith authored Nov 25, 2024
2 parents ca7bce5 + 79adc64 commit 70e2151
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.13.1 - 2024-11-24

### Internal

* Read the version from the git tag using setuptools-scm

## 1.13.0 - 2024-11-23

### Features
Expand Down
4 changes: 3 additions & 1 deletion litecli/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__version__ = "1.13.0"
import importlib.metadata

__version__ = importlib.metadata.version("litecli")
15 changes: 8 additions & 7 deletions litecli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,15 @@ def get_last_query(self):
return self.query_history[-1][0] if self.query_history else None


def version_callback(ctx: click.Context, param: click.Parameter, value: bool) -> None:
if not value or ctx.resilient_parsing:
return
click.echo(f"Version: {__version__}", color=ctx.color)
ctx.exit()


@click.command()
@click.option("-V", "--version", is_flag=True, help="Output litecli's version.")
@click.option("-V", "--version", callback=version_callback, expose_value=False, is_eager=True, is_flag=True, help="Show version.")
@click.option("-D", "--database", "dbname", help="Database to use.")
@click.option(
"-R",
Expand Down Expand Up @@ -859,7 +866,6 @@ def get_last_query(self):
def cli(
database,
dbname,
version,
prompt,
logfile,
auto_vertical_output,
Expand All @@ -876,11 +882,6 @@ def cli(
- litecli lite_database
"""

if version:
print("Version:", __version__)
sys.exit(0)

litecli = LiteCli(
prompt=prompt,
logfile=logfile,
Expand Down
11 changes: 3 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ dynamic = ["version"]
description = "CLI for SQLite Databases with auto-completion and syntax highlighting."
readme = "README.md"
requires-python = ">=3.7"
license = {text = "BSD"}
authors = [
{name = "dbcli", email = "[email protected]"}
]
license = { text = "BSD" }
authors = [{ name = "dbcli", email = "[email protected]" }]
urls = { "homepage" = "https://github.com/dbcli/litecli" }
dependencies = [
"cli-helpers[styles]>=2.2.1",
Expand All @@ -19,7 +17,7 @@ dependencies = [
]

[build-system]
requires = ["setuptools >= 61.0"]
requires = ["setuptools>=64.0", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"

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

[tool.setuptools.dynamic]
version = {attr = "litecli.__version__"}

[tool.ruff]
line-length = 140

0 comments on commit 70e2151

Please sign in to comment.