(args: argparse.Namespace)
| 288 | |
| 289 | |
| 290 | def cmd_validate(args: argparse.Namespace) -> int: |
| 291 | from researchclaw.config import validate_config |
| 292 | import yaml |
| 293 | |
| 294 | resolved = _resolve_config_or_exit(args) |
| 295 | if resolved is None: |
| 296 | return 1 |
| 297 | config_path = resolved |
| 298 | no_check_paths = cast(bool, args.no_check_paths) |
| 299 | |
| 300 | with config_path.open(encoding="utf-8") as f: |
| 301 | loaded = cast(object, yaml.safe_load(f)) |
| 302 | |
| 303 | if loaded is None: |
| 304 | data: dict[str, object] = {} |
| 305 | elif isinstance(loaded, dict): |
| 306 | loaded_map = cast(Mapping[object, object], loaded) |
| 307 | data = {str(key): value for key, value in loaded_map.items()} |
| 308 | else: |
| 309 | print("Config validation FAILED:") |
| 310 | print(" Error: Config root must be a mapping") |
| 311 | return 1 |
| 312 | |
| 313 | result = validate_config(data, check_paths=not no_check_paths) |
| 314 | if result.ok: |
| 315 | print("Config validation passed") |
| 316 | for w in result.warnings: |
| 317 | print(f" Warning: {w}") |
| 318 | return 0 |
| 319 | else: |
| 320 | print("Config validation FAILED:") |
| 321 | for e in result.errors: |
| 322 | print(f" Error: {e}") |
| 323 | return 1 |
| 324 | |
| 325 | |
| 326 | def cmd_doctor(args: argparse.Namespace) -> int: |
no test coverage detected