Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix: CLI paths not being resolved
NTFSvolume74804cb3d630
diff --git a/cyberdrop_dl/commands/__init__.py b/cyberdrop_dl/commands/__init__.pyindex a23153288..a466753da 100644--- a/cyberdrop_dl/commands/__init__.py+++ b/cyberdrop_dl/commands/__init__.py@@ -1,21 +1,37 @@+import dataclasses+from collections.abc import Sequence+from pathlib import Pathfrom typing import Annotated-from cyclopts import Parameter-from cyclopts.types import ResolvedExistingFile+from cyclopts import Parameter, Token, validators-from cyberdrop_dl.models import ConfigModelfrom cyberdrop_dl.models.types import HttpURL+def _resolve_path(type_: type[Path], tokens: Sequence[Token]) -> Path:+ assert len(tokens) == 1+ return type_(tokens[0].value).resolve()+++def file_validator(ext: str | tuple[str, ...], *, exists: bool = True) -> Parameter:+ return Parameter(validator=validators.Path(exists=exists, dir_okay=False, ext=ext), converter=_resolve_path)+++type YAMLFile = Annotated[Path, file_validator((".yaml", ".yml"))]+type JSONFile = Annotated[Path, file_validator(".json")]+type SQLiteFile = Annotated[Path, file_validator(".db")]++@Parameter(name="*")-class CLIarguments(ConfigModel):[email protected](slots=True, frozen=True)+class CLIarguments:urls: Annotated[tuple[HttpURL, ...], Parameter(show=False)] = ()- config_file: ResolvedExistingFile | None = None+ config_file: YAMLFile | None = None"YAML file to use as config"- cache_file: ResolvedExistingFile | None = None+ cache_file: JSONFile | None = None"JSON file to use as cache"- database_file: ResolvedExistingFile | None = None+ database_file: SQLiteFile | None = None"SQLite file to use as database"diff --git a/pyproject.toml b/pyproject.tomlindex 79cdf3c80..7d1369714 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -25,7 +25,7 @@ dependencies = ["brotli >=1.2.0; implementation_name=='cpython' and sys_platform!='ios'","certifi >=2026.6.17","curl-cffi >=0.15; implementation_name == 'cpython' ",- "cyclopts>=4.18.0",+ "cyclopts>=4.19.0","idna>=3.18","imagesize >=2.0.0","inquirer>=3.4.1",diff --git a/tests/test_cli.py b/tests/test_cli.pyindex 9e50d7386..9d40c5f42 100644--- a/tests/test_cli.py+++ b/tests/test_cli.py@@ -1,9 +1,21 @@+from pathlib import Path+import pytest+from cyclopts import App+from cyclopts.exceptions import ValidationErrorfrom cyberdrop_dl import __version__from cyberdrop_dl.__main__ import run_cdl+from cyberdrop_dl.commands import CLIargumentsfrom cyberdrop_dl.commands.report import generate_report+app = App(result_action="return_value", exit_on_error=False, suppress_keyboard_interrupt=False)+++def parse_cli_args(*, cli: CLIarguments | None = None) -> CLIarguments | None:+ return cli+@pytest.mark.parametrize(("command", "text"),@@ -26,3 +38,25 @@ def test_report() -> None:for value in "cyberdrop-dl", __version__, "aiohttp", "GIL enabled":assert value in report+++def test_cli_args_parsing(tmp_cwd: Path) -> None:+ cli = app([])+ assert cli is None+ config_yaml = Path("test_file.yaml")++ with pytest.raises(ValidationError, match="does not exist"):+ _ = app(["--config-file", config_yaml.name])++ config_text = config_yaml.with_suffix(".txt")+ config_text.touch()+ with pytest.raises(ValidationError, match='does not match one of supported extensions \\{"yaml", "yml"\\}'):+ _ = app(["--config-file", config_text.name])++ config_yaml.touch()+ config_yaml = config_yaml.with_suffix(".yaml")+ cli = app(["--config-file", config_yaml.name])+ assert type(cli) is CLIarguments+ assert cli.config_file == tmp_cwd / config_yaml+ assert cli.database_file is None+ assert cli.cache_file is Nonediff --git a/uv.lock b/uv.lockindex 65af170e7..b93b5ce95 100644--- a/uv.lock+++ b/uv.lock@@ -675,7 +675,7 @@ requires-dist = [{ name = "certifi", specifier = ">=2026.6.17" },{ name = "click", marker = "extra == 'apprise'", specifier = ">=8.4.1" },{ name = "curl-cffi", marker = "implementation_name == 'cpython'", specifier = ">=0.15" },- { name = "cyclopts", specifier = ">=4.18.0" },+ { name = "cyclopts", specifier = ">=4.19.0" },{ name = "idna", specifier = ">=3.18" },{ name = "imagesize", specifier = ">=2.0.0" },{ name = "inquirer", specifier = ">=3.4.1" },@@ -711,7 +711,7 @@ dev = [[[package]]name = "cyclopts"-version = "4.18.0"+version = "4.19.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "attrs" },@@ -719,9 +719,9 @@ dependencies = [{ name = "rich" },{ name = "rich-rst" },]-sdist = { url = "https://files.pythonhosted.org/packages/9a/19/5c438b428b3dca208eb920804dc16aeb3ca1e85d6163d17e8fb0785ead19/cyclopts-4.18.0.tar.gz", hash = "sha256:fb7b730f21932e0784f7e54462df0447aaa1fbf034d65b605bd8a25dce58b188", size = 182821, upload-time = "2026-06-11T19:55:05.326Z" }+sdist = { url = "https://files.pythonhosted.org/packages/65/e7/4b3048094559b86a800e0f0de7faf8e6d8213727cf31553ec58453f25abc/cyclopts-4.19.0.tar.gz", hash = "sha256:c7532803ab8560d4de8600769793c3de4b2dc8c3b23ec707b989d84d9bae6ff4", size = 189274, upload-time = "2026-06-22T23:58:54.176Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/5d/9f/b67f14c6b686ca90d317c0358f1a52ae171f43f83c808683fae3ba0b1f90/cyclopts-4.18.0-py3-none-any.whl", hash = "sha256:18ba2912e48e890a97ecc8a05c9beddf30a407b43f4e14cccfd40efddc41f029", size = 221216, upload-time = "2026-06-11T19:55:03.773Z" },+ { url = "https://files.pythonhosted.org/packages/eb/e8/b84c32f35a19107b55b8ceed260de9469206464da26bd0b979db470782c3/cyclopts-4.19.0-py3-none-any.whl", hash = "sha256:a8c11adb45afae25db310122950c7639c70b56e2ce341e5b29848bf3a8ecc1d4", size = 228005, upload-time = "2026-06-22T23:58:52.495Z" },][[package]]