Interactively install or uninstall semble across coding agents.
(mode: Mode)
| 179 | |
| 180 | |
| 181 | def run(mode: Mode) -> None: |
| 182 | """Interactively install or uninstall semble across coding agents.""" |
| 183 | install = mode == "install" |
| 184 | print(f"\n {_BOLD}{'Semble Installer' if install else 'Semble Uninstaller'}{_RESET}\n") |
| 185 | |
| 186 | agent_items = [ |
| 187 | (f"{a.display_name}{' (detected)' if (detected := is_detected(a)) else ''}", a, detected and install) |
| 188 | for a in sorted(AGENTS, key=lambda a: not is_detected(a)) |
| 189 | ] |
| 190 | chosen_agents = _checkbox( |
| 191 | f"Select agents to {'configure' if install else 'remove configuration from'}:", agent_items |
| 192 | ) or _exit("Nothing selected. Exiting.") |
| 193 | |
| 194 | max_label = max(len(i.label) for i in _INTEGRATIONS) |
| 195 | integ_items = [(f"{i.label:<{max_label}} — {i.desc}", i, True) for i in _INTEGRATIONS] |
| 196 | chosen_integrations = _checkbox( |
| 197 | f"Select integrations to {'enable' if install else 'remove'}:", integ_items |
| 198 | ) or _exit("Nothing selected. Exiting.") |
| 199 | |
| 200 | _print_plan(chosen_agents, chosen_integrations) |
| 201 | |
| 202 | question = "Proceed?" if install else "Remove semble configuration?" |
| 203 | if not questionary.confirm(question, default=install).ask(): |
| 204 | _exit("Cancelled.") |
| 205 | |
| 206 | _apply(mode, chosen_agents, chosen_integrations) |
| 207 | footer = " Restart your agents to pick up the changes." if install else "" |
| 208 | print(f" {_GREEN}Done!{_RESET}{footer}\n") |