Skip to content

Commit

Permalink
feat(cli): set max terminal width based on terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
mkniewallner committed Aug 25, 2024
1 parent ce87735 commit e3c1703
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion python/deptry/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import shutil
import sys
from collections import defaultdict
from importlib.metadata import version
Expand Down Expand Up @@ -240,7 +241,7 @@ def display_deptry_version(ctx: click.Context, _param: click.Parameter, value: b
is_flag=True,
help="Enable experimental support for namespace package (PEP 420) when detecting local modules (https://peps.python.org/pep-0420/).",
)
def deptry(
def cli(
root: tuple[Path, ...],
config: Path,
no_ansi: bool,
Expand Down Expand Up @@ -290,3 +291,9 @@ def deptry(
pep621_dev_dependency_groups=pep621_dev_dependency_groups,
experimental_namespace_package=experimental_namespace_package,
).run()


def deptry() -> None:
column_size, _line_size = shutil.get_terminal_size()

Check warning on line 297 in python/deptry/cli.py

View check run for this annotation

Codecov / codecov/patch

python/deptry/cli.py#L297

Added line #L297 was not covered by tests

cli(max_content_width=column_size)

Check warning on line 299 in python/deptry/cli.py

View check run for this annotation

Codecov / codecov/patch

python/deptry/cli.py#L299

Added line #L299 was not covered by tests
4 changes: 2 additions & 2 deletions tests/functional/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest
from click.testing import CliRunner

from deptry.cli import deptry
from deptry.cli import cli
from tests.functional.utils import Project
from tests.utils import get_issues_report, stylize

Expand Down Expand Up @@ -625,6 +625,6 @@ def test_cli_with_json_output(poetry_venv_factory: PoetryVenvFactory) -> None:


def test_cli_help() -> None:
result = CliRunner().invoke(deptry, "--help")
result = CliRunner().invoke(cli, "--help")

assert result.exit_code == 0

0 comments on commit e3c1703

Please sign in to comment.