Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHL-174: Multi-Step Commands #67



Copy link

  • Created a new @CliStepIndicator annotation to denote @CliCommand methods that have multiple steps
  • Created a new abstract class AbstractStepExecutionProcessor for permitting step-level control of commands
  • Added StepCommandsTest demonstrating the feature

Robin Howlett added 6 commits March 18, 2015 13:17
…t step processing; added annotation check to AbstractStepExecutionProcessor
- a @CliStepIndicator annotation
- an abstract class AbstractStepExecutionProcessor implementation of ExecutionProcessor
- exposing the shell logger
- storing if a step result has been handled already
- a test demonstrating it working
Copy link

Overall, I'm not too keen on adding this to the core of Spring Shell.

It is a rather specific solution to a specific problem and can be implemented without changing the core IMO (there is nothing preventing one from having command classes interact with some shared state that "knows" where we stand in a multi-step process). This could even leverage @CliAvailabilityIndicator.

Also, the provided example (the test) does nor really showcase how the added framework methods

stepConfig = configureStep(stepResult);
stepResult = executeStep(stepResult, stepConfig);
handleStepExecutionResult(invocationContext, stepResult);

are useful. Maybe a more real-world usecase would enlighten me.

Copy link

@ericbottard I understand your concerns and yes the test is a bit simple to demonstrate the feature.

The main reason I requested/provided this feature was that I was having some difficultly implementing a "user menu"-style of interaction with commands, specifically around commands that were returning data that had natural "next" or "previous" steps that I wanted to allow the user to choose to navigate to.

To show a more real-world use case, I created Mockbin CLI, a Spring Shell application that interacts with Mockbin.

The below GIF demonstrates an example use of a multi-step command. The command executes an request to Mockbin which returns a list of objects, prints those objects to an ASCII table and prompts the user to either enter the row number of an entry to be displayed in JSON, re-print the table, or exit the command execution. (The multiple output format support is part of SHL-175).

CLI Example

Copy link

Closing outdated PRs and issues

Copy link

A menu style interactive Command tool was quite useful.
Lots of user need this function.
Hope the spring-shell can support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants