Skip to content
Open
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
16 changes: 14 additions & 2 deletions insight/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
from .reporter import generate_report

def get_version():
"""Resolve package version without requiring setup.py on disk (pip installs)."""
try:
from importlib.metadata import version as pkg_version
return pkg_version("insight-cli-sarang")
except Exception:
pass
try:
from importlib.metadata import version as pkg_version
return pkg_version("insight")
except Exception:
pass
try:
from . import __version__
return __version__
Expand All @@ -15,8 +26,8 @@ def get_version():
setup_py = here / "setup.py"
if setup_py.exists():
with open(setup_py, "r") as f:
content = f.read()
match = re.search(r"version=\"(.*?)\"", content)
text = f.read()
match = re.search(r'version\s*=\s*["\'](.*?)["\']', text)
if match:
return match.group(1)
return "0.2.6"
Expand All @@ -38,6 +49,7 @@ def main():
analysis = analyze_codebase(args.path, limit=args.limit)

print("Generating reports...")

generate_report(analysis, args.output)

print(f"Reports saved in {args.output}/")
Expand Down