Package org.springframework.shell
Class Shell
java.lang.Object
org.springframework.shell.Shell
Main class implementing a shell loop.
-
Field Summary
Modifier and TypeFieldDescriptionprotected List<CompletionResolver>
static final Object
Marker object returned to signify that there was no input to turn into a command execution.protected static final Object
Marker object to distinguish unresolved arguments fromnull
, which is a valid value. -
Constructor Summary
ConstructorDescriptionShell
(ResultHandlerService resultHandlerService, CommandCatalog commandRegistry, org.jline.terminal.Terminal terminal, ShellContext shellContext, ExitCodeMappings exitCodeMappings) -
Method Summary
Modifier and TypeMethodDescriptioncomplete
(CompletionContext context) Gather completion proposals given some (incomplete) input the user has already typed in.protected Object
Evaluate a single "line" of input from the user by trying to map words to a command and arguments.void
run
(InputProvider inputProvider) The main program loop: acquire input, try to match it to a command and evaluate.void
setArgumentResolvers
(CommandExecution.CommandExecutionHandlerMethodArgumentResolvers argumentResolvers) void
setCompletionResolvers
(List<CompletionResolver> resolvers) void
setConversionService
(org.springframework.core.convert.ConversionService shellConversionService) void
setExceptionResolvers
(List<CommandExceptionResolver> exceptionResolvers) void
setExitCodeExceptionProvider
(ExitCodeExceptionProvider exitCodeExceptionProvider) void
setValidatorFactory
(jakarta.validation.ValidatorFactory validatorFactory)
-
Field Details
-
NO_INPUT
Marker object returned to signify that there was no input to turn into a command execution. -
completionResolvers
-
UNRESOLVED
Marker object to distinguish unresolved arguments fromnull
, which is a valid value.
-
-
Constructor Details
-
Shell
public Shell(ResultHandlerService resultHandlerService, CommandCatalog commandRegistry, org.jline.terminal.Terminal terminal, ShellContext shellContext, ExitCodeMappings exitCodeMappings)
-
-
Method Details
-
setCompletionResolvers
-
setArgumentResolvers
@Autowired public void setArgumentResolvers(CommandExecution.CommandExecutionHandlerMethodArgumentResolvers argumentResolvers) -
setConversionService
public void setConversionService(org.springframework.core.convert.ConversionService shellConversionService) -
setValidatorFactory
@Autowired(required=false) public void setValidatorFactory(jakarta.validation.ValidatorFactory validatorFactory) -
setExceptionResolvers
@Autowired(required=false) public void setExceptionResolvers(List<CommandExceptionResolver> exceptionResolvers) -
setExitCodeExceptionProvider
@Autowired(required=false) public void setExitCodeExceptionProvider(ExitCodeExceptionProvider exitCodeExceptionProvider) -
run
The main program loop: acquire input, try to match it to a command and evaluate. Repeat until aResultHandler
causes the process to exit or there is no input.This method has public visibility so that it can be invoked by actual commands (e.g. a script command).
- Throws:
Exception
-
evaluate
Evaluate a single "line" of input from the user by trying to map words to a command and arguments.This method does not throw exceptions, it catches them and returns them as a regular result
-
complete
Gather completion proposals given some (incomplete) input the user has already typed in. When and how this method is invoked is implementation specific and decided by the actual user interface.
-