add new shell command % replacement implementation #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add new command
%
replacement machinery.The new approach treats shell command replacement separately from mailcap file parsing.
That is, the command fields in the mailcap file are to be treated as opaque strings during
parsing and in the primary data type. Then this new machinery is used to take that opaque
string, and perform % substitution.
The substitutions are provided via the
ShellCommandReplacementActions m
record type.m
is some possibly-effectful context (e.g. IO).prepCommand
caches results of commandreplacement actions. The same replacement string occurring multiple times in the command
string does not result in the action being executed multiple times. See (or try for yourself)
the following example:
The result data type
ShellCommand
contains:%
substitutions applied[FilePath]
arising from%s
and%F
replacements. This is intended to assist cleanup (removal of temp files). Perhaps it could be aSet Filepath
instead.From purebred point of view, it would be necessary to construct the
ShellCommandReplacementActions
that returnproperties of the
MIMEMessage
(e.g. Content-Type or number of sub-parts), write body to temp files, etc.There are some TODOs. I also want to switch purebred-mailcap to depend on purebred-email and use the
ContentType
type from there.Feedback much appreciated!