public class Shell extends Object implements CommandRegistry
Given some textual input, locate the MethodTarget
to invoke and
handle
the result.
Also provides hooks for code completion
Modifier and Type | Field and Description |
---|---|
protected org.springframework.context.ApplicationContext |
applicationContext |
protected Map<String,MethodTarget> |
methodTargets |
static Object |
NO_INPUT
Marker object returned to signify that there was no input to turn into a command
execution.
|
protected List<ParameterResolver> |
parameterResolvers |
protected static Object |
UNRESOLVED
Marker object to distinguish unresolved arguments from
null , which is a valid
value. |
Constructor and Description |
---|
Shell(ResultHandler resultHandler) |
Modifier and Type | Method and Description |
---|---|
List<CompletionProposal> |
complete(CompletionContext context)
Gather completion proposals given some (incomplete) input the user has already typed
in.
|
Object |
evaluate(Input input)
Evaluate a single "line" of input from the user by trying to map words to a command and
arguments.
|
void |
gatherMethodTargets() |
Map<String,MethodTarget> |
listCommands()
Return the mapping from command trigger keywords to implementation.
|
void |
run(InputProvider inputProvider)
The main program loop: acquire input, try to match it to a command and evaluate.
|
void |
setParameterResolvers(List<ParameterResolver> resolvers) |
void |
setValidatorFactory(javax.validation.ValidatorFactory validatorFactory) |
public static final Object NO_INPUT
@Autowired protected org.springframework.context.ApplicationContext applicationContext
protected Map<String,MethodTarget> methodTargets
protected List<ParameterResolver> parameterResolvers
protected static final Object UNRESOLVED
null
, which is a valid
value.public Shell(ResultHandler resultHandler)
@Autowired(required=false) public void setValidatorFactory(javax.validation.ValidatorFactory validatorFactory)
public Map<String,MethodTarget> listCommands()
CommandRegistry
listCommands
in interface CommandRegistry
@PostConstruct public void gatherMethodTargets() throws Exception
Exception
@Autowired public void setParameterResolvers(List<ParameterResolver> resolvers)
public void run(InputProvider inputProvider) throws IOException
ResultHandler
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).
IOException
public Object evaluate(Input input)
This method does not throw exceptions, it catches them and returns them as a regular result
public List<CompletionProposal> complete(CompletionContext context)
Copyright © 2017 Pivotal Software, Inc.. All rights reserved.