dundalek/closh

Lifecycle hooks

Opened this issue · 2 comments

From a discussion in reddit:

Yes! Hook everything! There really cannot be too many hooks. Because of this, I think there should be a naming convention and/or namespace for them. Consider implementing the hook as a list of functions rather than just a single function. That will facilitate things like plugins, so multiple plugins can add hooks without monkey patching.

Naming ideas (in order of my decreasing preference):

  • closh.hook/logout
  • closh-hook-logout
  • closh-logout-hook

Ideas for hooks include but are very much not limited to:

  • login
  • logout
  • command-start (non-interactive)
  • command-finish (non-interactive)
  • prompt
  • pre-command (run after return is pressed but before command is processed)
  • post-command (run after command is processed but before control is handed back to user)

I'm here with a simple search in issues plugin.
The idea of Plugins is awesome on Closh.

Are there implementation attempt on these ?

I did not think about the design much yet. But I wonder if we could leverage some 3rd party library for that, something maybe like hooke.