Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion casbin_cli/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
__version__ = "1.0.0"
import subprocess


def get_base_tag():
try:
command = ["git", "describe", "--tags", "--abbrev=0"]

tag = subprocess.check_output(
command, text=True, stderr=subprocess.PIPE
).strip()

if tag.startswith("v"):
return tag[1:]
return tag

except subprocess.CalledProcessError:
print("Error: Failed to find any git tags.")
return None


__version__ = get_base_tag()
13 changes: 12 additions & 1 deletion casbin_cli/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ def run(args=None):
return ""
elif command_name in ['-v', '--version']:
print(f"casbin-python-cli {__version__}")
print("pycasbin 1.17.0")
try:
from importlib.metadata import version

pycasbin_version = version("pycasbin")
except ImportError:
try:
from importlib_metadata import version

pycasbin_version = version("pycasbin")
except (ImportError, Exception):
pycasbin_version = "unknown"
print(f"pycasbin {pycasbin_version}")
return ""
elif command_name == 'completion':
if len(args) < 2:
Expand Down