Skip to content

Commit

Permalink
read verbose from env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kzamlynska committed Dec 19, 2024
1 parent 4947470 commit 76ef33c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/ragbits-cli/src/ragbits/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib.util
import os
import pkgutil
from pathlib import Path
from typing import Annotated
Expand All @@ -8,6 +9,7 @@
from typer.main import get_command

import ragbits
from ragbits.core import audit

from .state import OutputType, cli_state, print_output

Expand All @@ -28,15 +30,17 @@ def ragbits_cli(
output: Annotated[
OutputType, typer.Option("--output", "-o", help="Set the output type (text or json)")
] = OutputType.text.value, # type: ignore
verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose mode"),
verbose: bool = typer.Option(
bool(int(os.getenv("RAGBITS_VERBOSE", "0"))), "--verbose", "-v", help="Enable verbose mode"
),
) -> None:
"""Common CLI arguments for all ragbits commands."""
cli_state.output_type = output
cli_state.verbose = verbose

if verbose:
typer.echo("Verbose mode is enabled.")
ragbits.core.audit.set_trace_handlers('cli')
audit.set_trace_handlers("cli")
else:
typer.echo("Verbose mode is disabled.")

Expand Down
1 change: 0 additions & 1 deletion packages/ragbits-core/src/ragbits/core/audit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from types import SimpleNamespace
from typing import Any, ParamSpec, TypeVar

from ragbits.cli import cli_state
from ragbits.core.audit.base import TraceHandler

__all__ = ["TraceHandler", "set_trace_handlers", "trace", "traceable"]
Expand Down

0 comments on commit 76ef33c

Please sign in to comment.