Switch from the current integration to a different one.
(
target: str = typer.Argument(help="Integration key to switch to"),
script: str | None = typer.Option(None, "--script", help="Script type: sh or ps (default: from init-options.json or platform default)"),
force: bool = typer.Option(False, "--force", help="Force removal of modified files during uninstall of the previous integration"),
refresh_shared_infra: bool = typer.Option(False, "--refresh-shared-infra", help="Also overwrite shared infrastructure files even if you customized them (otherwise customizations are preserved)"),
integration_options: str | None = typer.Option(None, "--integration-options", help='Options for the target integration'),
)
| 42 | |
| 43 | @integration_app.command("switch") |
| 44 | def integration_switch( |
| 45 | target: str = typer.Argument(help="Integration key to switch to"), |
| 46 | script: str | None = typer.Option(None, "--script", help="Script type: sh or ps (default: from init-options.json or platform default)"), |
| 47 | force: bool = typer.Option(False, "--force", help="Force removal of modified files during uninstall of the previous integration"), |
| 48 | refresh_shared_infra: bool = typer.Option(False, "--refresh-shared-infra", help="Also overwrite shared infrastructure files even if you customized them (otherwise customizations are preserved)"), |
| 49 | integration_options: str | None = typer.Option(None, "--integration-options", help='Options for the target integration'), |
| 50 | ): |
| 51 | """Switch from the current integration to a different one.""" |
| 52 | from . import INTEGRATION_REGISTRY, get_integration |
| 53 | from .manifest import IntegrationManifest |
| 54 | from .. import _print_cli_warning, _require_specify_project, _install_shared_infra_or_exit |
| 55 | |
| 56 | project_root = _require_specify_project() |
| 57 | target_integration = get_integration(target) |
| 58 | if target_integration is None: |
| 59 | console.print(f"[red]Error:[/red] Unknown integration '{target}'") |
| 60 | available = ", ".join(sorted(INTEGRATION_REGISTRY.keys())) |
| 61 | console.print(f"Available integrations: {available}") |
| 62 | raise typer.Exit(1) |
| 63 | |
| 64 | current = _read_integration_json(project_root) |
| 65 | installed_keys = _installed_integration_keys(current) |
| 66 | installed_key = _default_integration_key(current) |
| 67 | |
| 68 | if installed_key == target: |
| 69 | if integration_options is not None: |
| 70 | console.print( |
| 71 | "[red]Error:[/red] --integration-options cannot be used when switching " |
| 72 | "to an already installed integration." |
| 73 | ) |
| 74 | console.print( |
| 75 | f"Run [cyan]specify integration upgrade {target} --integration-options ...[/cyan] " |
| 76 | "to update managed files/options." |
| 77 | ) |
| 78 | raise typer.Exit(1) |
| 79 | if force: |
| 80 | raw_options, parsed_options = _resolve_integration_options( |
| 81 | target_integration, current, target, None |
| 82 | ) |
| 83 | _set_default_integration_or_exit( |
| 84 | project_root, |
| 85 | current, |
| 86 | target, |
| 87 | target_integration, |
| 88 | installed_keys, |
| 89 | raw_options=raw_options, |
| 90 | parsed_options=parsed_options, |
| 91 | refresh_templates_force=True, |
| 92 | ) |
| 93 | console.print( |
| 94 | f"\n[green]✓[/green] Default integration remains [bold]{target}[/bold]; " |
| 95 | "shared infrastructure refreshed." |
| 96 | ) |
| 97 | raise typer.Exit(0) |
| 98 | console.print(f"[yellow]Integration '{target}' is already the default integration. Nothing to switch.[/yellow]") |
| 99 | raise typer.Exit(0) |
| 100 | |
| 101 | if target in installed_keys: |
nothing calls this directly
no test coverage detected