How To Add A Command
How To Add A Command
Section titled “How To Add A Command”Adding a command usually touches both the application layer and, if it changes editor state, the domain layer.
Decision Tree
Section titled “Decision Tree”flowchart TD Start["New command"] --> Pure{"Does it change pure editor state?"} Pure -- Yes --> Domain["Add or reuse domain transition"] Pure -- No --> App["Add application/workbench behavior"] Domain --> Action["Map command to AppAction"] App --> Action Action --> Registry["Register in CommandRegistry defaults"] Registry --> Config["Optional: expose through config/keymaps"] Config --> Tests["Add tests in owning layer"]Typical Steps
Section titled “Typical Steps”- Add or reuse an
AppActioninrim-application/src/action.rs. - If the command changes pure editor state, add the transition in
rim-domain. - Handle the action in
rim-application/src/action_handler/. - Register the command in
rim-application/src/command.rs. - Add or update tests in the owning crate.
Where Not To Put It
Section titled “Where Not To Put It”- not in
rim-appunless it is runtime-only - not in an adapter unless it is purely host-specific input mapping
Config Exposure
Section titled “Config Exposure”If the command should be user-bindable:
- give it a stable command id in the registry
- ensure exported defaults include it
- confirm keymap/config load still works through
rim-application::config