Initial invoke trait and auto-indent example #466
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.
Here is a somewhat minimal implementation of invoking commands from validator trait.
General notes: it's unclear what to do with
command::Status
which can beProceed
orSubmit
. Currently it's ignored. But we may want to disable (i.e. assert on) commands returningSubmit
in validator and don't exposeStatus
type to the user?About auto-indent (#453), I've put mostly working example, but there are few ugly parts of the implementation:
execute
function. I use "empty message trick". But I'm not sure it's future-proof.So while auto-indentation is just one use case for
invoke
, I think at least (3) should be fixed somehow. Quick options are:validate_after_newline() -> bool { false }
that makes it optional for validator. Or (2a) have a config option, or (2b) have different method for post-validation.ValidationContext::skip_newline()
method, to skip adding newline after validation(note: (1) and (2) fix
RefCell
issue too, unlike (3))