Fetch command implementation for Lacuna CLI.
This module handles the 'lacuna fetch' subcommand for downloading,
processing, and registering connectomes.
Commands:
lacuna fetch gsp1000 - Download GSP1000 functional connectome
lacuna fetch dtor985 - Download dTOR985 structural tractogram
lacuna fetch --list - List available connectomes
lacuna fetch --interactive - Interactive guided setup
handle_fetch_command(args)
Handle the fetch subcommand.
Parameters:
| Name |
Type |
Description |
Default |
args
|
Namespace
|
Parsed command-line arguments.
|
required
|
Returns:
| Type |
Description |
int
|
Exit code (0 for success, non-zero for error).
|
Source code in src/lacuna/cli/fetch_cmd.py
| def handle_fetch_command(args: argparse.Namespace) -> int:
"""
Handle the fetch subcommand.
Parameters
----------
args : argparse.Namespace
Parsed command-line arguments.
Returns
-------
int
Exit code (0 for success, non-zero for error).
"""
# Import here to avoid circular imports and speed up CLI startup
# Handle --list flag
if getattr(args, "list", False):
return _handle_list()
# Handle --interactive flag
if getattr(args, "interactive", False):
return _handle_interactive(args)
# Handle --clean flag
if getattr(args, "clean", False):
return _handle_clean(args)
# Handle --clean-all flag
if getattr(args, "clean_all", False):
return _handle_clean_all(args)
# Handle specific connectome fetch
connectome = getattr(args, "connectome", None)
if connectome is None:
print("Error: No connectome specified. Use 'lacuna fetch --list' to see options.")
print(" Use 'lacuna fetch --interactive' for guided setup.")
return 1
if connectome == "gsp1000":
return _handle_gsp1000(args)
elif connectome == "dtor985":
return _handle_dtor985(args)
elif connectome in ("dtor985_10pct", "dtor985_25pct"):
return _handle_dtor985_subsample(args, connectome)
elif connectome == "hcp1065":
return _handle_hcp1065(args)
else:
print(f"Error: Unknown connectome '{connectome}'")
return 1
|