Separate interactive and non-interactive commands

- Add new ShellContext concept which now is just a way
  to stash info about interaction mode where ShellRunner
  can update supported mode.
- ShellMethod has a new field interactionMode which user
  can use to define commands between interactive/non-interactive
  modes which then prevents CommandRegistry to show
  commands at runtime.
- Fixes #345
This commit is contained in:
Janne Valkealahti
2022-01-09 14:10:15 +00:00
parent 3cb3309d68
commit dbe8a8b408
21 changed files with 284 additions and 32 deletions

View File

@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.shell.ConfigurableCommandRegistry;
import org.springframework.shell.MethodTarget;
import org.springframework.shell.context.DefaultShellContext;
import org.springframework.shell.standard.StandardMethodTargetRegistrar;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -32,7 +33,7 @@ public class CalculatorCommandsTest extends BaseCalculatorTest {
private static final Class<CalculatorCommands> COMMAND_CLASS_UNDER_TEST = CalculatorCommands.class;
private final ConfigurableCommandRegistry registry = new ConfigurableCommandRegistry();
private final ConfigurableCommandRegistry registry = new ConfigurableCommandRegistry(new DefaultShellContext());
@Autowired
private CalculatorState state;