Package org.springframework.shell.jline
Class NonInteractiveShellRunner
java.lang.Object
org.springframework.shell.jline.NonInteractiveShellRunner
- All Implemented Interfaces:
ShellRunner
A
ShellRunner that executes commands without entering interactive shell mode.
Has higher precedence than InteractiveShellRunner which gives it an opportunity to handle the shell
in non-interactive fashion.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe precedence at which this runner is ordered by the DefaultApplicationRunner - which also controls the order it is consulted on the ability to handle the current shell. -
Constructor Summary
ConstructorsConstructorDescriptionNonInteractiveShellRunner(Shell shell, ShellContext shellContext) NonInteractiveShellRunner(Shell shell, ShellContext shellContext, String primaryCommand) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRun(org.springframework.boot.ApplicationArguments args) Checks if a particular shell runner can execute.voidrun(org.springframework.boot.ApplicationArguments args) Execute application.voidsetCommandsFromInputArgs(Function<org.springframework.boot.ApplicationArguments, List<String>> commandsFromInputArgs) Sets the function that creates the command() to run from the input application arguments.voidsetLineParser(org.jline.reader.Parser lineParser) Sets the line parser used to parse commands.
-
Field Details
-
PRECEDENCE
public static final int PRECEDENCEThe precedence at which this runner is ordered by the DefaultApplicationRunner - which also controls the order it is consulted on the ability to handle the current shell.- See Also:
-
-
Constructor Details
-
NonInteractiveShellRunner
-
NonInteractiveShellRunner
-
-
Method Details
-
setCommandsFromInputArgs
public void setCommandsFromInputArgs(Function<org.springframework.boot.ApplicationArguments, List<String>> commandsFromInputArgs) Sets the function that creates the command() to run from the input application arguments.- Parameters:
commandsFromInputArgs- function that takes input application arguments and creates zero or more commands where each command is a string that specifies the command and options (eg. 'history --file myHistory.txt')
-
setLineParser
public void setLineParser(org.jline.reader.Parser lineParser) Sets the line parser used to parse commands.- Parameters:
lineParser- the line parser used to parse commands
-
canRun
public boolean canRun(org.springframework.boot.ApplicationArguments args) Description copied from interface:ShellRunnerChecks if a particular shell runner can execute.- Specified by:
canRunin interfaceShellRunner- Parameters:
args- the application arguments- Returns:
- true if shell runner can execute
-
run
Description copied from interface:ShellRunnerExecute application.- Specified by:
runin interfaceShellRunner- Parameters:
args- the application argumets- Throws:
Exception- in errors
-