Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/core/cli/app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
"""ragctl CLI Application (Typer-based)."""
import logging
import warnings
import typer
from pathlib import Path
from typing import Optional
from typing_extensions import Annotated
from src.core.cli.utils.display import set_verbosity
from src.core.cli.commands.chunk import ChunkStrategy


# Suppress common warnings for better UX
warnings.filterwarnings("ignore", category=FutureWarning, module="transformers")
warnings.filterwarnings("ignore", message=".*TRANSFORMERS_CACHE.*")
Expand Down Expand Up @@ -46,12 +49,27 @@ def main(
version: Annotated[
bool,
typer.Option(
"--version", "-v",
"--version", "-V",
help="Show version and exit",
callback=version_callback,
is_eager=True
)
] = False,
quiet: Annotated[
bool,
typer.Option(
"--quiet", "-q",
help="Quiet mode: errors only"
)
] = False,
verbose: Annotated[
int,
typer.Option(
"--verbose", "-v",
help="Increase verbosity (-v for info/debug, -vv for full details)",
count=True
)
] = 0,
):
"""
RAG Studio - Production-ready RAG toolkit with intelligent document processing.
Expand Down Expand Up @@ -85,7 +103,19 @@ def main(
Support:
Report issues at: https://github.com/datallmhub/ragctl/issues
"""
pass
if quiet and verbose > 0:
raise typer.BadParameter("Cannot use --quiet with --verbose/--vv")

logging_level = logging.WARNING
if quiet:
logging_level = logging.ERROR
elif verbose >= 2:
logging_level = logging.DEBUG
elif verbose == 1:
logging_level = logging.INFO

logging.basicConfig(level=logging_level, force=True)
set_verbosity(level=verbose, quiet=quiet)


# Register commands - imports happen inside each command function (lazy loading)
Expand Down
23 changes: 21 additions & 2 deletions src/core/cli/utils/display.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
"""Display utilities for CLI using Rich."""
from typing import List, Dict, Any
from rich.console import Console
from rich.table import Table
from rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn, TaskProgressColumn
from typing import List, Dict, Any

console = Console()
_verbosity_level = 0

Check notice

Code scanning / CodeQL

Unused global variable Note

The global variable '_verbosity_level' is not used.
_quiet_mode = False


def set_verbosity(level: int = 0, quiet: bool = False) -> None:
"""Configure display verbosity and quiet mode."""
global _verbosity_level, _quiet_mode, console
_verbosity_level = level

Check notice

Code scanning / CodeQL

Unused global variable Note

The global variable '_verbosity_level' is not used.
_quiet_mode = quiet
console = Console(quiet=quiet)


def print_success(message: str) -> None:
"""Print success message."""
if _quiet_mode:
return
console.print(f"[green]✓[/green] {message}")


Expand All @@ -19,11 +31,15 @@ def print_error(message: str) -> None:

def print_warning(message: str) -> None:
"""Print warning message."""
if _quiet_mode:
return
console.print(f"[yellow]⚠[/yellow] {message}")


def print_info(message: str) -> None:
"""Print info message."""
if _quiet_mode:
return
console.print(f"[cyan]ℹ[/cyan] {message}")


Expand Down Expand Up @@ -61,12 +77,15 @@ def create_batch_progress() -> Progress:
TextColumn("[progress.description]{task.description}"),
BarColumn(),
TaskProgressColumn(),
console=console
console=console,
disable=_quiet_mode,
)


def display_stats(stats: Dict[str, Any]) -> None:
"""Display statistics in a formatted way."""
if _quiet_mode:
return
table = Table(show_header=False, box=None)
table.add_column("Metric", style="cyan", no_wrap=True)
table.add_column("Value", style="white")
Expand Down