Enable a disabled extension.
(
extension: str = typer.Argument(help="Extension ID or name to enable"),
)
| 1445 | |
| 1446 | @extension_app.command("enable") |
| 1447 | def extension_enable( |
| 1448 | extension: str = typer.Argument(help="Extension ID or name to enable"), |
| 1449 | ): |
| 1450 | """Enable a disabled extension.""" |
| 1451 | from . import ExtensionManager, HookExecutor |
| 1452 | |
| 1453 | project_root = _require_specify_project() |
| 1454 | manager = ExtensionManager(project_root) |
| 1455 | hook_executor = HookExecutor(project_root) |
| 1456 | |
| 1457 | # Resolve extension ID from argument (handles ambiguous names) |
| 1458 | installed = manager.list_installed() |
| 1459 | extension_id, display_name = _resolve_installed_extension(extension, installed, "enable") |
| 1460 | |
| 1461 | # Update registry |
| 1462 | metadata = manager.registry.get(extension_id) |
| 1463 | if metadata is None or not isinstance(metadata, dict): |
| 1464 | console.print( |
| 1465 | f"[red]Error:[/red] Extension '{_escape_markup(str(extension_id))}' " |
| 1466 | "not found in registry (corrupted state)" |
| 1467 | ) |
| 1468 | raise typer.Exit(1) |
| 1469 | |
| 1470 | if metadata.get("enabled", True): |
| 1471 | console.print(f"[yellow]Extension '{_escape_markup(str(display_name))}' is already enabled[/yellow]") |
| 1472 | raise typer.Exit(0) |
| 1473 | |
| 1474 | manager.registry.update(extension_id, {"enabled": True}) |
| 1475 | |
| 1476 | # Enable hooks in extensions.yml |
| 1477 | config = hook_executor.get_project_config() |
| 1478 | if "hooks" in config: |
| 1479 | for hook_name in config["hooks"]: |
| 1480 | for hook in config["hooks"][hook_name]: |
| 1481 | if hook.get("extension") == extension_id: |
| 1482 | hook["enabled"] = True |
| 1483 | hook_executor.save_project_config(config) |
| 1484 | |
| 1485 | console.print(f"[green]✓[/green] Extension '{_escape_markup(str(display_name))}' enabled") |
| 1486 | |
| 1487 | |
| 1488 | @extension_app.command("disable") |
nothing calls this directly
no test coverage detected