"""
Test CLI functionality
"""
import pytest
import subprocess
import sys
from pathlib import Path


def test_cli_version():
    """Test version command."""
    result = subprocess.run(
        [sys.executable, "-m", "juicekeggers.cli", "--version"],
        capture_output=True,
        text=True
    )
    assert "juiceKEGGers" in result.stdout
    assert result.returncode == 0


def test_cli_help():
    """Test help command."""
    result = subprocess.run(
        [sys.executable, "-m", "juicekeggers.cli", "--help"],
        capture_output=True,
        text=True
    )
    assert "juiceKEGGers" in result.stdout
    assert "commands" in result.stdout
    assert result.returncode == 0


def test_cli_no_args():
    """Test CLI with no arguments shows help."""
    result = subprocess.run(
        [sys.executable, "-m", "juicekeggers.cli"],
        capture_output=True,
        text=True
    )
    assert "juiceKEGGers" in result.stdout
    assert result.returncode == 0


def test_cli_info_command():
    """Test info command."""
    result = subprocess.run(
        [sys.executable, "-m", "juicekeggers.cli", "info"],
        capture_output=True,
        text=True
    )
    # Just check it runs without error
    assert result.returncode == 0 or result.returncode == 1  # 1 if dependencies missing


def test_cli_config_command():
    """Test config command."""
    result = subprocess.run(
        [sys.executable, "-m", "juicekeggers.cli", "config", "--list"],
        capture_output=True,
        text=True
    )
    assert "Configuration" in result.stdout or "Current configuration" in result.stdout
    assert result.returncode == 0
	