Disable an extension without removing it.
(
extension: str = typer.Argument(help="Extension ID or name to disable"),
)
| 1487 | |
| 1488 | @extension_app.command("disable") |
| 1489 | def extension_disable( |
| 1490 | extension: str = typer.Argument(help="Extension ID or name to disable"), |
| 1491 | ): |
| 1492 | """Disable an extension without removing it.""" |
| 1493 | from . import ExtensionManager, HookExecutor |
| 1494 | |
| 1495 | project_root = _require_specify_project() |
| 1496 | manager = ExtensionManager(project_root) |
| 1497 | hook_executor = HookExecutor(project_root) |
| 1498 | |
| 1499 | # Resolve extension ID from argument (handles ambiguous names) |
| 1500 | installed = manager.list_installed() |
| 1501 | extension_id, display_name = _resolve_installed_extension(extension, installed, "disable") |
| 1502 | |
| 1503 | # Update registry |
| 1504 | metadata = manager.registry.get(extension_id) |
| 1505 | if metadata is None or not isinstance(metadata, dict): |
| 1506 | console.print( |
| 1507 | f"[red]Error:[/red] Extension '{_escape_markup(str(extension_id))}' " |
| 1508 | "not found in registry (corrupted state)" |
| 1509 | ) |
| 1510 | raise typer.Exit(1) |
| 1511 | |
| 1512 | if not metadata.get("enabled", True): |
| 1513 | console.print(f"[yellow]Extension '{_escape_markup(str(display_name))}' is already disabled[/yellow]") |
| 1514 | raise typer.Exit(0) |
| 1515 | |
| 1516 | manager.registry.update(extension_id, {"enabled": False}) |
| 1517 | |
| 1518 | # Disable hooks in extensions.yml |
| 1519 | config = hook_executor.get_project_config() |
| 1520 | if "hooks" in config: |
| 1521 | for hook_name in config["hooks"]: |
| 1522 | for hook in config["hooks"][hook_name]: |
| 1523 | if hook.get("extension") == extension_id: |
| 1524 | hook["enabled"] = False |
| 1525 | hook_executor.save_project_config(config) |
| 1526 | |
| 1527 | console.print(f"[green]✓[/green] Extension '{_escape_markup(str(display_name))}' disabled") |
| 1528 | console.print("\nCommands will no longer be available. Hooks will not execute.") |
| 1529 | console.print(f"To re-enable: specify extension enable {_escape_markup(str(extension_id))}") |
| 1530 | |
| 1531 | |
| 1532 | @extension_app.command("set-priority") |
nothing calls this directly
no test coverage detected