mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 03:40:38 +08:00
Refactor CLI argument handling and request processing
This commit is contained in:
@ -9,14 +9,6 @@ from pr_agent.log import setup_logger
|
||||
setup_logger()
|
||||
|
||||
|
||||
def handle_args_with_quotes(args):
|
||||
if args.rest:
|
||||
for i, r in enumerate(args.rest):
|
||||
if r.startswith("--") and r.count("=") == 1 and " " in r:
|
||||
r_split = r.split("=")
|
||||
args.rest[i] = r_split[0] + "=" + '"' + r_split[1] + '"'
|
||||
return args
|
||||
|
||||
|
||||
def run(inargs=None):
|
||||
parser = argparse.ArgumentParser(description='AI based pull request analyzer', usage=
|
||||
@ -54,7 +46,6 @@ For example: 'python cli.py --pr_url=... review --pr_reviewer.extra_instructions
|
||||
parser.add_argument('command', type=str, help='The', choices=commands, default='review')
|
||||
parser.add_argument('rest', nargs=argparse.REMAINDER, default=[])
|
||||
args = parser.parse_args(inargs)
|
||||
args = handle_args_with_quotes(args)
|
||||
if not args.pr_url and not args.issue_url:
|
||||
parser.print_help()
|
||||
return
|
||||
@ -62,9 +53,9 @@ For example: 'python cli.py --pr_url=... review --pr_reviewer.extra_instructions
|
||||
command = args.command.lower()
|
||||
get_settings().set("CONFIG.CLI_MODE", True)
|
||||
if args.issue_url:
|
||||
result = asyncio.run(PRAgent().handle_request(args.issue_url, command + " " + " ".join(args.rest)))
|
||||
result = asyncio.run(PRAgent().handle_request(args.issue_url, [command] + args.rest))
|
||||
else:
|
||||
result = asyncio.run(PRAgent().handle_request(args.pr_url, command + " " + " ".join(args.rest)))
|
||||
result = asyncio.run(PRAgent().handle_request(args.pr_url, [command] + args.rest))
|
||||
if not result:
|
||||
parser.print_help()
|
||||
|
||||
|
Reference in New Issue
Block a user