Merge CLI scripts to cli.py, update Dockerfile and README.md

This commit is contained in:
Ori Kotek
2023-07-06 11:37:44 +03:00
parent aa1c32c714
commit 987befe457
5 changed files with 34 additions and 39 deletions

27
pr_agent/cli.py Normal file
View File

@ -0,0 +1,27 @@
import argparse
import asyncio
import logging
import os
from pr_agent.tools.pr_questions import PRQuestions
from pr_agent.tools.pr_reviewer import PRReviewer
def run():
parser = argparse.ArgumentParser(description='AI based pull request analyzer')
parser.add_argument('--pr_url', type=str, help='The URL of the PR to review', required=True)
parser.add_argument('--question', type=str, help='Optional question to ask', required=False)
args = parser.parse_args()
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
if args.question:
print(f"Question: {args.question} about PR {args.pr_url}")
reviewer = PRQuestions(args.pr_url, args.question, None)
asyncio.run(reviewer.answer())
else:
print(f"Reviewing PR: {args.pr_url}")
reviewer = PRReviewer(args.pr_url, None)
asyncio.run(reviewer.review())
if __name__ == '__main__':
run()