Skip to content

Commit 2ae9ba2

Browse files
authored
Add version option to cli and dynamic versioning (linkml#144)
* Add version option to cli and dynamic versioning * Set same auto-versioning style as in LinkML
1 parent 168936d commit 2ae9ba2

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

pyproject.toml

+7-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,13 @@ lxml = ">=4.9.1"
6868
llm = ">=0.12"
6969

7070
[build-system]
71-
requires = ["poetry-core>=1.0.0"]
72-
build-backend = "poetry.core.masonry.api"
71+
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
72+
build-backend = "poetry_dynamic_versioning.backend"
73+
74+
[tool.poetry-dynamic-versioning]
75+
enable = true
76+
vcs = "git"
77+
style = "pep440"
7378

7479
[tool.poetry.scripts]
7580
schemauto = "schema_automator.cli:main"

schema_automator/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
from importlib import metadata
2+
13
from schema_automator.annotators import *
24
from schema_automator.importers import *
35
from schema_automator.generalizers import *
6+
7+
try:
8+
__version__ = metadata.version(__package__)
9+
except metadata.PackageNotFoundError:
10+
# package is not installed
11+
__version__ = "0.0.0" # pragma: no cover

schema_automator/cli.py

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from schema_automator.importers.sql_import_engine import SqlImportEngine
3434
from schema_automator.importers.tabular_import_engine import TableImportEngine
3535
from schema_automator.utils.schemautils import write_schema
36+
from schema_automator import __version__
3637

3738
input_option = click.option(
3839
"-i",
@@ -80,6 +81,7 @@
8081
help="Set the level of verbosity")
8182
@click.option("-q", "--quiet",
8283
help="Silence all diagnostics")
84+
@click.version_option(__version__, "-V", "--version")
8385
def main(verbose: int, quiet: bool):
8486
"""Run the LinkML Schema Automator Command Line.
8587

0 commit comments

Comments
 (0)