Commit 923ae915 authored by Jan Reimes's avatar Jan Reimes
Browse files

🔧 chore(cli): replace console prints with logger calls

parent 4255be33
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -10,14 +10,16 @@ from pathlib import Path
import typer

from tdoc_crawler.cli.console import get_console
from tdoc_crawler.logging import get_logger

console = get_console()
logger = get_logger(__name__)


def launch_file(path: Path) -> None:
    """Launch file in system's default application."""
    if not path.exists():
        console.print(f"[red]File not found: {path}")
        logger.error(f"File not found: {path}")
        raise typer.Exit(code=1)
    try:
        if sys.platform.startswith("win"):
@@ -27,14 +29,14 @@ def launch_file(path: Path) -> None:
            if open_cmd.exists():
                subprocess.run([str(open_cmd), str(path)], check=False)  # noqa: S603
            else:
                console.print("[yellow]/usr/bin/open not available[/yellow]")
                logger.warning("/usr/bin/open not available")
        else:
            # Linux and other Unix-like systems
            xdg_cmd = Path("/usr/bin/xdg-open")
            if xdg_cmd.exists():
                subprocess.run([str(xdg_cmd), str(path)], check=False)  # noqa: S603
            else:
                console.print("[yellow]xdg-open command not available[/yellow]")
                logger.warning("xdg-open command not available")
    except OSError as exc:
        console.print(f"[red]Failed to open file: {exc}")
        logger.error(f"Failed to open file: {exc}")
        raise typer.Exit(code=1) from exc