Skip to content
Closed
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
58 changes: 30 additions & 28 deletions insight/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,44 @@
from .analyzer import analyze_codebase
from .reporter import generate_report

def get_version():
try:
from . import __version__
return __version__
except Exception:
pass
here = pathlib.Path(__file__).parent.parent
setup_py = here / "setup.py"
if setup_py.exists():
class Insight:
def __init__(self):
self.version = self.get_version()

def get_version(self):
here = pathlib.Path(__file__).parent.parent
setup_py = here / "setup.py"
with open(setup_py, "r") as f:
content = f.read()
match = re.search(r"version=\"(.*?)\"", content)
if match:
return match.group(1)
return "0.2.6"

def main():
parser = argparse.ArgumentParser(description="Insight - Codebase Explainer CLI")
parser.add_argument("--version", action="version", version=f"%(prog)s {get_version()}")
parser.add_argument("path", help="Path to the codebase")
parser.add_argument("-o", "--output", default="report", help="Output report directory")
parser.add_argument("--limit", type=int, default=None, help="Limit number of files analyzed")
args = parser.parse_args()
return "0.0.0"

if not os.path.exists(args.path):
print(f"Error: Path '{args.path}' not found.")
print(f" • Current directory: {os.getcwd()}")
return

print("Analyzing codebase...")
analysis = analyze_codebase(args.path, limit=args.limit)
def run(self):
parser = argparse.ArgumentParser(description="Insight - Codebase Explainer CLI")
parser.add_argument("--version", action="version", version=f"%(prog)s {self.get_version()}")
parser.add_argument("path", help="Path to the codebase")
parser.add_argument("-o", "--output", default="report", help="Output report directory")
parser.add_argument("--limit", type=int, default=None, help="Limit number of files analyzed")
args = parser.parse_args()

print("Generating reports...")
generate_report(analysis, args.output)
if not os.path.exists(args.path):
print(f"❌ Error: Path '{args.path}' not found.")
print(f" • Current directory: {os.getcwd()}")
return

print(f"Reports saved in {args.output}/")
print("Analyzing codebase...")
analysis = analyze_codebase(args.path, limit=args.limit)

print("Generating reports...")
generate_report(analysis, args.output)

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

def main():
insight = Insight()
insight.run()

if __name__ == "__main__":
main()