@module: sce.cli
@depends: sce.io
@exports: main
@paper_ref: N/A
@data_flow: CLI args -> dataset utilities
main
Command-line interface for SCE dataset utilities.
Source code in sce/cli.py
| def main() -> int:
"""Command-line interface for SCE dataset utilities."""
parser = _build_parser()
args = parser.parse_args()
if args.command != "datasets":
parser.print_help()
return 0
if args.datasets_command == "list":
for info in list_datasets():
location = "local" if info.exists_locally else "missing"
if info.remote_source is not None:
remote = info.remote_source
elif info.source == "generated":
remote = "generated-local-build"
else:
remote = "bundled"
print(f"{info.name}: {location} | source={remote}")
return 0
if args.datasets_command == "info":
info = get_dataset_info(args.dataset)
remote_source = info.remote_source
if remote_source is None:
remote_source = "generated-local-build" if info.source == "generated" else "bundled"
print(f"name: {info.name}")
print(f"path: {info.path}")
print(f"description: {info.description}")
print(f"source: {info.source}")
print(f"remote_source: {remote_source}")
print(f"exists_locally: {info.exists_locally}")
if info.size_bytes is not None:
print(f"size_bytes: {info.size_bytes}")
return 0
if args.datasets_command == "download":
path = ensure_dataset(args.dataset, force_download=args.force)
print(path)
return 0
if args.datasets_command == "verify":
results = verify_all_datasets()
for name, is_valid in results.items():
status = "OK" if is_valid else "INVALID"
print(f"{name}: {status}")
return 0 if all(results.values()) else 1
datasets_parser = next(
action for action in parser._actions if isinstance(action, argparse._SubParsersAction)
)
datasets_parser.choices["datasets"].print_help()
return 0
|