"""WordPress shell commands"""
import click

from praisonaiwp.core.transport import get_transport
from praisonaiwp.core.config import Config
from praisonaiwp.core.wp_client import WPClient


@click.command()
@click.option('--server', help='Server name from config')
def shell(server):
    """Interactive WordPress shell."""
    config = Config()
    transport = get_transport(config, server)
    transport.connect()
    client = WPClient(ssh, config.get_server(server)['wp_path'] if server else None)
    
    click.echo("Starting WordPress shell. Type 'exit' to quit.")
    
    while True:
        try:
            command = input("wp> ")
            if command.lower() in ['exit', 'quit']:
                break
            
            if command.strip():
                result = client.cli(command)
                click.echo(result)
        except KeyboardInterrupt:
            break
    
    click.echo("WordPress shell closed.")
