Skip to content

Commit 16a2cf3

Browse files
authored
fix: reuse config parser for cli (#4187)
1 parent 9c95d0f commit 16a2cf3

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

openhands/core/cli.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import argparse
21
import asyncio
32
import logging
43
from typing import Type
@@ -10,6 +9,7 @@
109
from openhands.controller import AgentController
1110
from openhands.controller.agent import Agent
1211
from openhands.core.config import (
12+
get_parser,
1313
load_app_config,
1414
)
1515
from openhands.core.logger import openhands_logger as logger
@@ -63,10 +63,10 @@ def display_event(event: Event):
6363
display_command_output(event.content)
6464

6565

66-
def get_parser() -> argparse.ArgumentParser:
67-
"""Get the parser for the command line arguments."""
68-
parser = argparse.ArgumentParser(description='Run an agent with a specific task')
66+
async def main():
67+
"""Runs the agent in CLI mode"""
6968

69+
parser = get_parser()
7070
# Add the version argument
7171
parser.add_argument(
7272
'-v',
@@ -76,14 +76,6 @@ def get_parser() -> argparse.ArgumentParser:
7676
help='Show the version number and exit',
7777
default=None,
7878
)
79-
80-
return parser
81-
82-
83-
async def main():
84-
"""Runs the agent in CLI mode"""
85-
86-
parser = get_parser()
8779
args = parser.parse_args()
8880

8981
if args.version:

0 commit comments

Comments
 (0)