Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: add some option aliases

NTFSvolumebea0f18b9f93
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8a45ada49..43221507f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Twitter/x.com support
- `show` command now accepts a `--json` flag to output sites as a JSON array
+- New CLI aliases for `--config-file`: `--config`, `-c`
+- New CLI aliase for `--database-file`: `--db`
+- New CLI aliase for `--proxy`: `--http-proxy`
### Changed
diff --git a/cyberdrop_dl/commands/__init__.py b/cyberdrop_dl/commands/__init__.py
index b81a9b65a..fda961e51 100644
--- a/cyberdrop_dl/commands/__init__.py
+++ b/cyberdrop_dl/commands/__init__.py
@@ -23,13 +23,13 @@ type SQLiteFile = Annotated[Path, file_validator(".db")]
@Parameter(name="*")
@dataclasses.dataclass(slots=True)
class CLIarguments:
- config_file: YAMLFile | None = None
+ config_file: Annotated[YAMLFile | None, Parameter(alias=("-c", "config"))] = None
"YAML file to use as config"
cache_file: JSONFile | None = None
"JSON file to use as cache"
- database_file: SQLiteFile | None = None
+ database_file: Annotated[SQLiteFile | None, Parameter(alias=("db"))] = None
"SQLite file to use as database"
def __iter__(self) -> Generator[tuple[str, Path | None]]:
diff --git a/cyberdrop_dl/config/settings.py b/cyberdrop_dl/config/settings.py
index be557e415..00cb4876f 100644
--- a/cyberdrop_dl/config/settings.py
+++ b/cyberdrop_dl/config/settings.py
@@ -321,7 +321,7 @@ class Network(ConfigGroup):
flaresolverr: FalsyAsNone[HttpURL] = None
"HTTP URL of an existing flaresolverr instance"
- proxy: FalsyAsNone[HttpURL] = None
+ proxy: Annotated[FalsyAsNone[HttpURL], Parameter(alias=("http-proxy"))] = None
"HTTP/HTTPS proxy"
rate_limit: PositiveFloat = 25
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 2ce6ea279..503b7ff46 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -2,7 +2,7 @@ from pathlib import Path
import pytest
from cyclopts import App
-from cyclopts.exceptions import ValidationError
+from cyclopts.exceptions import RepeatArgumentError, ValidationError
from cyberdrop_dl import __version__
from cyberdrop_dl.__main__ import run_cdl
@@ -10,7 +10,7 @@ from cyberdrop_dl.commands import CLIarguments
from cyberdrop_dl.commands.report import generate_report
from cyberdrop_dl.config import Config
-app = App(result_action="return_value", exit_on_error=False, suppress_keyboard_interrupt=False)
+app = App(result_action="return_value", print_error=False, exit_on_error=False, suppress_keyboard_interrupt=False)
@app.default()
@@ -61,6 +61,8 @@ def test_cli_args_parsing(tmp_cwd: Path) -> None:
assert cli.config_file == tmp_cwd / config_yaml
assert cli.database_file is None
assert cli.cache_file is None
+ cli = app(["-c", config_yaml.name])
+ assert cli.config_file == tmp_cwd / config_yaml
def test_custom_bool_parsing() -> None:
@@ -74,3 +76,11 @@ def test_custom_bool_parsing() -> None:
assert config.sort.enabled
config = Config.parse_args("--no-sort")
assert not config.sort.enabled
+
+
+def test_cli_multi_args() -> None:
+ config = Config.parse_args(["--skip-hosts", "a", "b", "c"])
+ assert config.filters.skip_hosts == {"a", "b", "c"}
+
+ with pytest.raises(RepeatArgumentError):
+ Config.parse_args(["--skip-hosts", "a", "--skip-hosts", "b", "c"])