cowboy mode
This commit is contained in:
parent
c3fe7aa360
commit
04cb8db2b9
|
|
@ -0,0 +1,17 @@
|
||||||
|
import random
|
||||||
|
|
||||||
|
COWBOY_MESSAGES = [
|
||||||
|
"Yeeehaw! 🤠",
|
||||||
|
"Yippee ki yay motherfucker! 🤠",
|
||||||
|
"Saddle up partner! 🤠",
|
||||||
|
"This ain't my first rodeo! 🤠",
|
||||||
|
"Lock and load, partner! 🤠"
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_cowboy_message() -> str:
|
||||||
|
"""Randomly select and return a cowboy message.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: A randomly selected cowboy message
|
||||||
|
"""
|
||||||
|
return random.choice(COWBOY_MESSAGES)
|
||||||
|
|
@ -6,6 +6,7 @@ from rich.prompt import Confirm
|
||||||
from ra_aid.tools.memory import _global_memory
|
from ra_aid.tools.memory import _global_memory
|
||||||
from ra_aid.proc.interactive import run_interactive_command
|
from ra_aid.proc.interactive import run_interactive_command
|
||||||
from ra_aid.text.processing import truncate_output
|
from ra_aid.text.processing import truncate_output
|
||||||
|
from ra_aid.console.cowboy_messages import get_cowboy_message
|
||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
|
|
||||||
|
|
@ -45,6 +46,9 @@ def run_shell_command(command: str) -> Dict[str, Union[str, int, bool]]:
|
||||||
# Check if we need approval
|
# Check if we need approval
|
||||||
cowboy_mode = _global_memory.get('config', {}).get('cowboy_mode', False)
|
cowboy_mode = _global_memory.get('config', {}).get('cowboy_mode', False)
|
||||||
|
|
||||||
|
if cowboy_mode:
|
||||||
|
console.print(get_cowboy_message())
|
||||||
|
|
||||||
if not cowboy_mode:
|
if not cowboy_mode:
|
||||||
if not Confirm.ask("Execute this command?", default=True):
|
if not Confirm.ask("Execute this command?", default=True):
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import pytest
|
||||||
|
from ra_aid.console.cowboy_messages import get_cowboy_message, COWBOY_MESSAGES
|
||||||
|
|
||||||
|
def test_get_cowboy_message_returns_string():
|
||||||
|
"""Test that get_cowboy_message returns a non-empty string"""
|
||||||
|
message = get_cowboy_message()
|
||||||
|
assert isinstance(message, str)
|
||||||
|
assert len(message) > 0
|
||||||
|
|
||||||
|
def test_cowboy_message_contains_emoji():
|
||||||
|
"""Test that returned message contains the cowboy emoji"""
|
||||||
|
message = get_cowboy_message()
|
||||||
|
assert '🤠' in message
|
||||||
|
|
||||||
|
def test_message_from_predefined_list():
|
||||||
|
"""Test that returned message is from our predefined list"""
|
||||||
|
message = get_cowboy_message()
|
||||||
|
assert message in COWBOY_MESSAGES
|
||||||
|
|
@ -30,6 +30,18 @@ def test_shell_command_cowboy_mode(mock_console, mock_confirm, mock_run_interact
|
||||||
assert "test output" in result['output']
|
assert "test output" in result['output']
|
||||||
mock_confirm.ask.assert_not_called()
|
mock_confirm.ask.assert_not_called()
|
||||||
|
|
||||||
|
def test_shell_command_cowboy_message(mock_console, mock_confirm, mock_run_interactive):
|
||||||
|
"""Test that cowboy mode displays a cowboy message"""
|
||||||
|
_global_memory['config'] = {'cowboy_mode': True}
|
||||||
|
|
||||||
|
with patch('ra_aid.tools.shell.get_cowboy_message') as mock_get_message:
|
||||||
|
mock_get_message.return_value = '🤠 Test cowboy message!'
|
||||||
|
result = run_shell_command("echo test")
|
||||||
|
|
||||||
|
assert result['success'] is True
|
||||||
|
mock_console.print.assert_any_call('🤠 Test cowboy message!')
|
||||||
|
mock_get_message.assert_called_once()
|
||||||
|
|
||||||
def test_shell_command_interactive_approved(mock_console, mock_confirm, mock_run_interactive):
|
def test_shell_command_interactive_approved(mock_console, mock_confirm, mock_run_interactive):
|
||||||
"""Test shell command execution with interactive approval"""
|
"""Test shell command execution with interactive approval"""
|
||||||
_global_memory['config'] = {'cowboy_mode': False}
|
_global_memory['config'] = {'cowboy_mode': False}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue