feat: add initial uipath explainator implementation
Scaffold project with pyproject.toml and environment configuration Implement core modules including CLI, Gemini integration, and scanner
This commit is contained in:
50
src/uipath_explainator/cli.py
Normal file
50
src/uipath_explainator/cli.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from pathlib import Path
|
||||
|
||||
from .config import Settings
|
||||
from .gemini import GeminiAnalyzer
|
||||
from .pipeline import ProjectPipeline
|
||||
|
||||
|
||||
def build_parser() -> ArgumentParser:
|
||||
parser = ArgumentParser(description="Extract and explain UiPath project dependencies.")
|
||||
parser.add_argument("project_dir", type=Path, help="UiPath project root directory")
|
||||
parser.add_argument("--output-dir", type=Path, default=Path("workspace"), help="Copied project output directory")
|
||||
parser.add_argument("--entry", default="main.xaml", help="Entry XAML file name")
|
||||
parser.add_argument("--env-file", type=Path, default=Path(".env"), help="Environment file for Gemini config")
|
||||
parser.add_argument("--model", help="Override GEMINI_MODEL")
|
||||
parser.add_argument("--skip-analysis", action="store_true", help="Skip Gemini analysis and only prepare files")
|
||||
parser.add_argument("--force", action="store_true", help="Overwrite the output directory if it already exists")
|
||||
return parser
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
parser = build_parser()
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
project_root = args.project_dir.expanduser().resolve()
|
||||
if not project_root.is_dir():
|
||||
parser.error(f"Project directory does not exist: {project_root}")
|
||||
|
||||
output_dir = args.output_dir.expanduser()
|
||||
if not output_dir.is_absolute():
|
||||
output_dir = Path.cwd() / output_dir
|
||||
|
||||
settings = Settings.from_env(args.env_file if args.env_file.exists() else None, model_override=args.model)
|
||||
analyzer = None if args.skip_analysis else GeminiAnalyzer(settings)
|
||||
|
||||
pipeline = ProjectPipeline(
|
||||
project_root=project_root,
|
||||
output_root=output_dir,
|
||||
entry_name=args.entry,
|
||||
force=args.force,
|
||||
)
|
||||
report = pipeline.run(analyzer=analyzer)
|
||||
|
||||
print(f"Output written to: {report.output_root}")
|
||||
print(f"Final files: {len(report.final_files)}")
|
||||
print(f"Pruned files: {len(report.pruned_files)}")
|
||||
print(f"Warnings: {len(report.warnings)}")
|
||||
return 0
|
||||
Reference in New Issue
Block a user