Out of the box, Spring Shell supports printing command results to the terminal in a fairly basic way.
Spring Shell also provides the
ExecutionProcessor interface, allowing a “command provider to be called in a generic fashion just before, and right after, executing a command”.
The interface defines three lifecycle events that can be intercepted:
- before a command has been invoked
- after an invocation has been returned
- after an exception was thrown
I was interested in hooking into the
afterReturningInvocation to provide “step logic” - potentially allowing user or system input to execute additional logic based on the result of the initial command result (and/or each step result) e.g. paging backwards or forwards on the command line through lists of data.