Skip to content

Commit

Permalink
feat: add debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
01Joseph-Hwang10 committed May 15, 2024
1 parent f8e5f06 commit 29b3a8a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ ldm install
> ldm install clamp
> ```

### Debugging

If you need to debug the installation process, you can run `ldm install --debug` to see the logs.

```bash
ldm install --debug
```

## API Documentation

> TODO: description
Expand Down
2 changes: 1 addition & 1 deletion ldm/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa: F401

from ._cli import cli
from ._logger import get_debug_level, create_logger
from ._logger import create_logger
5 changes: 3 additions & 2 deletions ldm/cli/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ def cli():

@cli.command("install")
@click.argument("dependencies", nargs=-1)
def install(dependencies: list[str]):
logger = create_logger()
@click.option("--debug", is_flag=True, default=False)
def install(dependencies: list[str], debug: bool):
logger = create_logger(debug)

command = InstallCommand(logger=logger)
error_boundary(
Expand Down
9 changes: 2 additions & 7 deletions ldm/cli/_logger.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import os
from typing import Callable
from ..logger import Logger, ClickLogger


def get_debug_level() -> int:
debug = os.environ.get("DEBUG", None)
return 1 if debug else 2


def create_logger(level: int = get_debug_level()) -> ClickLogger:
def create_logger(debug: bool) -> ClickLogger:
level = 1 if debug else 2
return ClickLogger(level=level)


Expand Down

0 comments on commit 29b3a8a

Please sign in to comment.