Coverage for src / check_datapackage / cli.py: 0%
15 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-02 14:17 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-02 14:17 +0000
1"""Functions for the exposed CLI."""
3from pathlib import Path
4from typing import Any
6from seedcase_soil import (
7 pretty_print,
8 run_without_tracebacks,
9 setup_cli,
10)
12from check_datapackage.check import check
13from check_datapackage.config import Config
14from check_datapackage.read_json import read_json
16app = setup_cli(
17 name="check-datapackage",
18 help=(
19 "check-datapackage checks if metadata is compliant with the Data Package"
20 "standard"
21 ),
22 config_name=".cdp.toml",
23)
26@app.command(name="check")
27def check_cmd(
28 source: str = "datapackage.json",
29 *,
30 strict: bool = False,
31) -> None:
32 """Check a Data Package's metadata against the Data Package standard.
34 Outputs a human-readable explanation of any issues found.
36 Args:
37 source: The local location of a `datapackage.json` file.
38 strict: If True, check "SHOULD" properties in addition to "MUST"
39 properties from the Data Package standard.
40 """
41 properties: dict[str, Any] = read_json(Path(source))
42 config = Config(strict=strict)
43 check(properties, config=config, error=True)
44 pretty_print("[green]All checks passed! Your Data Package is valid.[/green]")
47def main() -> None:
48 """Create an entry point to run the cli without tracebacks."""
49 run_without_tracebacks(app)