org.overlord.sramp.shell.api
Interface ShellCommand

All Known Implementing Classes:
AbstractShellCommand

public interface ShellCommand

Interface implemented by all shell commands.

Author:
eric.wittmann@redhat.com

Method Summary
 void execute()
          Called to execute the command.
 void print(String formattedMessage, Object... params)
          Prints the given message to the output stream.
 void printHelp()
          Prints the help text for this command.
 void printUsage()
          Prints the usage help for this command.
 void setArguments(Arguments arguments)
          Sets the arguments that can be used by this command.
 void setContext(ShellContext context)
          The shell context.
 void setOutput(Writer output)
          Configure the command's output.
 int tabCompletion(String lastArgument, List<CharSequence> candidates)
          Handle tab completion for the command.
 

Method Detail

setArguments

void setArguments(Arguments arguments)
Sets the arguments that can be used by this command.

Parameters:
arguments -

setOutput

void setOutput(Writer output)
Configure the command's output.

Parameters:
output -

setContext

void setContext(ShellContext context)
The shell context.

Parameters:
context -

execute

void execute()
             throws Exception
Called to execute the command.

Throws:
Exception

printUsage

void printUsage()
Prints the usage help for this command.


printHelp

void printHelp()
Prints the help text for this command.


print

void print(String formattedMessage,
           Object... params)
Prints the given message to the output stream.

Parameters:
formattedMessage -
params -

tabCompletion

int tabCompletion(String lastArgument,
                  List<CharSequence> candidates)
Handle tab completion for the command. This is optional, but provides a mechanism by which individual commands can enable command-specific tab completion functionality. The return value of this method represents the cursor position within lastArgument that represents the origin point for all of the candidates. Return 0 to indicate that the candidates are all full-replacements of lastArgument. Return -1 to indicate that no candidates were supplied. Return a positive, non-negative value if the returned candidates are partial completions. For example, if the user has typed "aar", then a command could return any of: candidates=[] rval=-1 candidates=["aardvark", "aardwolf"] rval=0 candidates=["dvark", "dwolf"] rval=3 In the latter two examples, the tab-completion will be the same, but the user will be shown the different candidate values (when more than 1 candidate is returned).

Parameters:
lastArgument -
candidates -
Returns:
the cursor position


Copyright © 2011-2013 JBoss, a division of Red Hat. All Rights Reserved.