From b65ac4e0f4ccfcdf6715cf99c5093c0dc22ee78f Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 12 Dec 2024 20:25:57 +0100 Subject: [PATCH] Check for community installation (#2692) Related #https://github.com/cursorless-dev/cursorless/issues/1953 ## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --------- Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> --- cursorless-talon/src/check_community_repo.py | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cursorless-talon/src/check_community_repo.py diff --git a/cursorless-talon/src/check_community_repo.py b/cursorless-talon/src/check_community_repo.py new file mode 100644 index 0000000000..4338af21ce --- /dev/null +++ b/cursorless-talon/src/check_community_repo.py @@ -0,0 +1,36 @@ +from talon import app, registry + +required_captures = [ + "number_small", + "user.any_alphanumeric_key", + "user.formatters", + "user.ordinals_small", +] + +required_actions = [ + "user.homophones_get", + "user.reformat_text", +] + + +def on_ready(): + missing_captures = [ + capture for capture in required_captures if capture not in registry.captures + ] + missing_actions = [ + action for action in required_actions if action not in registry.actions + ] + errors = [] + if missing_captures: + errors.append(f"Missing captures: {', '.join(missing_captures)}") + if missing_actions: + errors.append(f"Missing actions: {', '.join(missing_actions)}") + if errors: + print("\n".join(errors)) + app.notify( + "Please install the community repository", + body="https://github.com/talonhub/community", + ) + + +app.register("ready", on_ready)