using System;
using Avalonia.Media;
using Cogwheel;

namespace SessionZero.Cogwheel;

public class SessionZeroConsole : ICogwheelConsole
{
    public string OpeningMessage { get; set; } = "SessionZero Console";
    public bool IsRunning { get; set; }
    public CommandsManager CommandsManager { get; set; }
    
    public void Initialize(CommandsManager commandsManager)
    {
        CommandsManager = commandsManager;
    }

    public void Log(string message)
    {
        Console.WriteLine(message);
        AppManager.ConsoleControl.Log(message);
    }

    public void LogError(string message)
    {
        Console.WriteLine("Error: " + message);
        AppManager.ConsoleControl.Log($"Error: {message}", Colors.Red);
    }

    public void LogWarning(string message)
    {
        Console.WriteLine("Warning: " + message);
        AppManager.ConsoleControl.Log($"Warning: {message}", Colors.Yellow);
    }

    public void Write(string message)
    {
        Console.Write(message);
    }

    public void ClearConsole()
    {
        AppManager.ConsoleControl.ClearOutput();
    }

    public void Exit()
    {
        AppManager.HideConsole();
    }
}