def add_crm_venv() -> Do: handle = yield Ribo.setting(handle_crm) if handle: log.debug('adding chromatin venv') plugin = Rplugin.simple('chromatin') yield Ribo.modify_main(lambda a: a.set.chromatin_rplugin(Just(plugin))) yield Ribo.modify_main( lambda a: a.set.chromatin_venv(Just('chromatin')))
def bootstrap_rplugins_io() -> Do: vr = yield installable_plugins() dir = yield Ribo.setting(venv_dir) global_interpreter = yield Ribo.setting_raw(interpreter) ios = yield vr.traverse( lambda a: bootstrap_rplugin(a, dir, global_interpreter.to_maybe) (a.meta), NS) yield NS.pure(GatherIOs(ios, timeout=30))
def health_statuses() -> Do: dir = yield Ribo.setting(venv_dir) all_venvs = yield Ribo.inspect_main(lambda a: a.venvs) log.debug(f'running health check on venvs: {all_venvs.join_comma}') installable = yield Ribo.zoom_main( all_venvs.traverse(lambda a: installable_rplugin_from_name(dir, a), NS)) gather_items = yield installable.traverse( lambda a: rplugin_healthy(a.rplugin)(a.meta), NS) return Gather(gather_items, 5)
def read_conf() -> Do: plugin_conf = yield Ribo.setting(rplugins) specs = plugin_conf.traverse(Rplugin.from_config, Either) yield NS.from_either(specs)
def activate_newly_installed() -> Do: new = yield Ribo.zoom_main(NS.inspect_either(lambda a: a.inactive)) yield activate_multi(new) yield Ribo.zoom_main(activation_complete())
def reboot_plugins(plugins: List[str]) -> Do: yield Ribo.zoom_main(deactivate_by_names(plugins)) yield activate_by_names(plugins)
def activate_by_names(plugins: List[str]) -> Do: getter = (lambda a: a.ready_rplugins) if plugins.empty else ( lambda a: a.ready_by_name(plugins)) rplugins = yield Ribo.zoom_main(NS.inspect_either(getter)) yield (NS.error(resources.no_plugins_match_for_activation(plugins)) if rplugins.empty else activate_multi(rplugins))
def activate_multi(new_rplugins: List[Rplugin]) -> Do: active = yield Ribo.zoom_main( NS.inspect_either(lambda a: a.active_rplugins)) active_rplugins = active.map(lambda a: a.rplugin) already_active, inactive = new_rplugins.split(active_rplugins.contains) yield inactive.traverse(activate_rplugin, NS).replace(already_active)
def activate_rplugin(rplugin: Rplugin) -> Do: active_rplugin = yield NS.lift(activate_rplugin_io.match(rplugin)) yield Ribo.zoom_main(activated(active_rplugin))
def installable_plugins() -> Do: plugins = yield Ribo.inspect_main(lambda a: a.rplugins) return plugins.flat_map(cons_installable_rplugin.match)
def initialize() -> Do: yield add_crm_venv() yield Ribo.zoom_main(read_conf())
def show_plugins() -> Do: dir = yield Ribo.setting(venv_dir) rplugins = yield Ribo.inspect_main(lambda a: a.rplugins) return Echo.info(resources.show_plugins(dir, rplugins))
def add_plugins(rplugins: List[Rplugin]) -> None: yield Ribo.zoom_main(NS.modify(lambda s: s.append.rplugins(rplugins))) yield Ribo.setting(autostart)
def updateable_venvs(plugins: List[str]) -> Do: dir = yield Ribo.setting(venv_dir) yield Ribo.zoom_main(updateable(dir, plugins).nvim)