mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
CLI(V1) (#11220)
Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: Xingyao Wang <xingyao@all-hands.dev>
This commit is contained in:
38
openhands/cli/deprecation_warning.py
Normal file
38
openhands/cli/deprecation_warning.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""Deprecation warning utilities for the old OpenHands CLI."""
|
||||
|
||||
import sys
|
||||
|
||||
from prompt_toolkit import print_formatted_text
|
||||
from prompt_toolkit.formatted_text import HTML
|
||||
|
||||
|
||||
def display_deprecation_warning() -> None:
|
||||
"""Display a prominent deprecation warning for the old CLI interface."""
|
||||
warning_lines = [
|
||||
'',
|
||||
'⚠️ DEPRECATION WARNING ⚠️',
|
||||
'',
|
||||
'This CLI interface is deprecated and will be removed in a future version.',
|
||||
'Please migrate to the new OpenHands CLI:',
|
||||
'',
|
||||
'For more information, visit: https://docs.all-hands.dev/usage/how-to/cli-mode',
|
||||
'',
|
||||
'=' * 70,
|
||||
'',
|
||||
]
|
||||
|
||||
# Print warning with prominent styling
|
||||
for line in warning_lines:
|
||||
if 'DEPRECATION WARNING' in line:
|
||||
print_formatted_text(HTML(f'<ansired><b>{line}</b></ansired>'))
|
||||
elif line.startswith(' •'):
|
||||
print_formatted_text(HTML(f'<ansigreen>{line}</ansigreen>'))
|
||||
elif 'https://' in line:
|
||||
print_formatted_text(HTML(f'<ansiblue>{line}</ansiblue>'))
|
||||
elif line.startswith('='):
|
||||
print_formatted_text(HTML(f'<ansiyellow>{line}</ansiyellow>'))
|
||||
else:
|
||||
print_formatted_text(HTML(f'<ansiyellow>{line}</ansiyellow>'))
|
||||
|
||||
# Flush to ensure immediate display
|
||||
sys.stdout.flush()
|
||||
@@ -15,6 +15,8 @@ This implementation addresses GitHub issue #10698, which reported that
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from openhands.cli.deprecation_warning import display_deprecation_warning
|
||||
|
||||
|
||||
def get_fast_cli_parser() -> argparse.ArgumentParser:
|
||||
"""Create a lightweight argument parser for CLI help command."""
|
||||
@@ -148,6 +150,7 @@ def handle_fast_commands() -> bool:
|
||||
"""
|
||||
# Handle --help or -h
|
||||
if len(sys.argv) == 2 and sys.argv[1] in ('--help', '-h'):
|
||||
display_deprecation_warning()
|
||||
parser = get_fast_cli_parser()
|
||||
|
||||
# Print top-level help
|
||||
@@ -166,6 +169,8 @@ def handle_fast_commands() -> bool:
|
||||
if len(sys.argv) == 2 and sys.argv[1] in ('--version', '-v'):
|
||||
import openhands
|
||||
|
||||
display_deprecation_warning()
|
||||
|
||||
print(f'OpenHands CLI version: {openhands.get_version()}')
|
||||
return True
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ from openhands.cli.commands import (
|
||||
check_folder_security_agreement,
|
||||
handle_commands,
|
||||
)
|
||||
from openhands.cli.deprecation_warning import display_deprecation_warning
|
||||
from openhands.cli.settings import modify_llm_settings_basic
|
||||
from openhands.cli.shell_config import (
|
||||
ShellConfigManager,
|
||||
@@ -779,3 +780,6 @@ def run_cli_command(args):
|
||||
except Exception as e:
|
||||
print_formatted_text(f'Error during cleanup: {e}')
|
||||
sys.exit(1)
|
||||
finally:
|
||||
# Display deprecation warning on exit
|
||||
display_deprecation_warning()
|
||||
|
||||
@@ -32,6 +32,7 @@ from prompt_toolkit.shortcuts import print_container
|
||||
from prompt_toolkit.widgets import Frame, TextArea
|
||||
|
||||
from openhands import __version__
|
||||
from openhands.cli.deprecation_warning import display_deprecation_warning
|
||||
from openhands.cli.pt_style import (
|
||||
COLOR_AGENT_BLUE,
|
||||
COLOR_GOLD,
|
||||
@@ -151,6 +152,9 @@ def display_initialization_animation(text: str, is_loaded: asyncio.Event) -> Non
|
||||
|
||||
|
||||
def display_banner(session_id: str) -> None:
|
||||
# Display deprecation warning first
|
||||
display_deprecation_warning()
|
||||
|
||||
print_formatted_text(
|
||||
HTML(r"""<gold>
|
||||
___ _ _ _
|
||||
|
||||
Reference in New Issue
Block a user