|
This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Shell 3.4.1! |
Execution
This section describes how to set up a Spring Shell to work in interactive mode.
Interaction Mode
Version 2.1.x introduced built-in support to distinguish between interactive and non-interactive modes. This makes it easier to use the shell as a simple command-line tool without requiring customization.
Currently, interactive mode is entered if any command line options are passed when starting or running a shell from a command line. This works especially well when a shell application is compiled with Native Support.
Some commands may not have any useful meanings when they run in interactive mode
or (conversely) in non-interactive mode. For example, a built-in exit command would
have no meaning in non-interactive mode, because it is used to exit interactive mode.
Shell Runners
ShellRunner is the main interface to run a shell. There can be only one ShellRunner
per application context.
Three ShellRunner implementations exist, named SystemShellRunner,
JLineShellRunner and NonInteractiveShellRunner. By default, it is
the interactive SystemShellRunner that is used.
To enable non-interactive mode, you can set the spring.shell.interactive.enabled
property to false. This will switch the ShellRunner implementation to
NonInteractiveShellRunner.
Debug Mode
Spring Shell provides a debug mode that can be enabled by setting the
spring.shell.debug.enabled property to true. When enabled, this mode
provides additional debugging information for command execution by printing
stack traces of errors, which can be useful for troubleshooting and development purposes.