From 16a2cf37da8995bda7f8075f797062fae3e0427e Mon Sep 17 00:00:00 2001 From: Xingyao Wang Date: Thu, 3 Oct 2024 08:41:02 -0500 Subject: [PATCH] fix: reuse config parser for cli (#4187) --- openhands/core/cli.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/openhands/core/cli.py b/openhands/core/cli.py index fafad7e1162..9f978c26c96 100644 --- a/openhands/core/cli.py +++ b/openhands/core/cli.py @@ -1,4 +1,3 @@ -import argparse import asyncio import logging from typing import Type @@ -10,6 +9,7 @@ from openhands.controller import AgentController from openhands.controller.agent import Agent from openhands.core.config import ( + get_parser, load_app_config, ) from openhands.core.logger import openhands_logger as logger @@ -63,10 +63,10 @@ def display_event(event: Event): display_command_output(event.content) -def get_parser() -> argparse.ArgumentParser: - """Get the parser for the command line arguments.""" - parser = argparse.ArgumentParser(description='Run an agent with a specific task') +async def main(): + """Runs the agent in CLI mode""" + parser = get_parser() # Add the version argument parser.add_argument( '-v', @@ -76,14 +76,6 @@ def get_parser() -> argparse.ArgumentParser: help='Show the version number and exit', default=None, ) - - return parser - - -async def main(): - """Runs the agent in CLI mode""" - - parser = get_parser() args = parser.parse_args() if args.version: