Skip to content

Commit

Permalink
Merge pull request #446 from Codium-ai/tr/fix_cli_args
Browse files Browse the repository at this point in the history
Handling CLI Arguments with Quotes in pr_agent
  • Loading branch information
okotek authored Nov 12, 2023
2 parents 37e6608 + 9e5e9af commit 1df36c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions pr_agent/agent/pr_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ async def handle_request(self, pr_url, request, notify=None) -> bool:
apply_repo_settings(pr_url)

# Then, apply user specific settings if exists
request = request.replace("'", "\\'")
lexer = shlex.shlex(request, posix=True)
lexer.whitespace_split = True
action, *args = list(lexer)
if isinstance(request, str):
request = request.replace("'", "\\'")
lexer = shlex.shlex(request, posix=True)
lexer.whitespace_split = True
action, *args = list(lexer)
else:
action, *args = request
args = update_settings_from_args(args)

action = action.lstrip("/").lower()
Expand Down
6 changes: 4 additions & 2 deletions pr_agent/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

setup_logger()



def run(inargs=None):
parser = argparse.ArgumentParser(description='AI based pull request analyzer', usage=
"""\
Expand Down Expand Up @@ -51,9 +53,9 @@ def run(inargs=None):
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()

Expand Down

0 comments on commit 1df36c6

Please sign in to comment.