"""Main Slices CLI.

This CLI mostly calls others CLIs.
"""

import os
from pathlib import Path

from slices_cli.console import DummyConsole, LazyRichConsole

console = LazyRichConsole(log_path=False)
err_console = LazyRichConsole(stderr=True)

DEBUG_LEVEL_INFO = 1
DEBUG_LEVEL_DEBUG = 2
DEBUG_LEVEL_TRACE = 3

try:
    DEBUG_LEVEL = int(os.environ.get("SLICES_DEBUG", "0"))
except ValueError:
    DEBUG_LEVEL = 0
    err_console.print("[red bold] :x: ignoring SLICES_DEBUG environment variable: not an integer", highlight=False)

console_info = LazyRichConsole(log_path=False) if DEBUG_LEVEL >= DEBUG_LEVEL_INFO else DummyConsole()
console_debug = LazyRichConsole(log_path=False) if DEBUG_LEVEL >= DEBUG_LEVEL_DEBUG else DummyConsole()
console_trace = LazyRichConsole(log_path=False) if DEBUG_LEVEL >= DEBUG_LEVEL_TRACE else DummyConsole()

CONFIG_DIR = ".slices"
config_dir_location = Path.home() / CONFIG_DIR
cache_dir_location = config_dir_location / "cache"
