purebred-mua / purebred

A terminal based mail user agent based on notmuch
GNU Affero General Public License v3.0
139 stars 19 forks source link

add plugin system #415

Closed frasertweedale closed 3 years ago

frasertweedale commented 3 years ago

Add a plugin system. The design of the system is described in [1] Also provide a built-in plugin to add the User-Agent header to outgoing mail (fixes #414).

Further improvements to the system and documentation will follow in subsequent commits.

[1] https://frasertweedale.github.io/blog-fp/posts/2021-02-02-plugin-system-prototype.html

Fixes: https://github.com/purebred-mua/purebred/issues/414

frasertweedale commented 3 years ago

Ooof, CI fails in Haddock with a compile error related to the code itself. i.e. a bug in haddock, probably?

frasertweedale commented 3 years ago

Hm, it's caused by a difference in haddock's use of .hs-boot files. Probably still a bug, but I've worked around it.

romanofski commented 3 years ago

Hey @frasertweedale, this is awesome! I'd merge it right away, however I think we should clarify how this plugin system sits with what we currently use with https://github.com/purebred-mua/purebred-icu. Will purebred-icu remain a different plugin or would we be migrating it? I guess what I'm getting at, perhaps it makes sense to have different points of Purebred and it's config pluggable, or rather have one spot, where plugins can be loaded?

frasertweedale commented 3 years ago

Nono, do not merge it yet. Lots more goodness to come.

purebred-icu is a kind of plugin, but doesn't hook anything, just twiddles some config. However, it could be integrated with the plugin system by defining an "initConfig" hook that gets access to twiddle the config. Which is a reasonable way to do it, and would provide consistent UX. So I will probably migrate it.

frasertweedale commented 3 years ago

@romanofski ready for review now. I did implement a ConfigHook. I would like to rename purebredWithPlugins to purebred, i.e. make it the primary (or only) entry point - a backwards incompatible change. But LMK what you think about that. It can be done later as a small and separate change, anyhow.

I look forward to adding more hooks to do interesting things :) PGP plugin is the next yak to shave, while I avoid the dreaded crash bug :S

romanofski commented 3 years ago

@romanofski ready for review now. I did implement a ConfigHook. I would like to rename purebredWithPlugins to purebred, i.e. make it the primary (or only) entry point - a backwards incompatible change. But LMK what you think about that. It can be done later as a small and separate change, anyhow.

Yeah go ahead. It's not that we've released 1.0 or any version as of yet. So IMHO totally fine to make a backwards incompatible change.