org.jboss.forge.shell
Interface Shell

All Superinterfaces:
ShellHistory, ShellPrintWriter, ShellPrompt

public interface Shell
extends ShellPrintWriter, ShellPrompt, ShellHistory

Author:
Lincoln Baxter, III

Method Summary
 void clear()
          Clear the console.
 void clearLine()
          Clear the current line of any text.
 void cursorLeft(int x)
          Move the cursor x the specified number of positions.
 void execute(File file)
          Execute a shell script from the specified file.
 void execute(File file, String... args)
          Execute a shell script from the specified file, passing the given arguments as input.
 void execute(String command)
          Execute a shell command.
 DirectoryResource getConfigDir()
          Return the file-system directory currently in use as the configuration directory.
 DirectoryResource getCurrentDirectory()
          Return the current working directory resource of the shell.
 Project getCurrentProject()
          Return the Project on which this shell instance is currently operating.
 Resource<?> getCurrentResource()
          Return the current working Resource of the shell.
 Class<? extends Resource<?>> getCurrentResourceScope()
          Return the type of the Resource on which the Shell is currently operating.
 ForgeEnvironment getEnvironment()
          Get the current Forge environment.
 int getHeight()
          Return the current height, in characters, of the current shell console.
 String getPrompt()
          Return the current shell prompt;
 int getWidth()
          Return the current width, in characters, of the current shell console.
 boolean isAnsiSupported()
          Returns whether or not this shell supports ANSI escape codes.
 boolean isExecuting()
          Return true if the Shell is currently executing a plugin; otherwise, return false.
 boolean isPretend()
          Return true if this shell is currently running in pretend mode.
 boolean isVerbose()
          Return true if this shell is currently running in verbose mode.
 void printlnVerbose(ShellColor color, String output)
          Write color output to the console, only if isVerbose() == true.
 void printlnVerbose(String output)
          Write output to the console, only if isVerbose() == true.
 String readLine()
          Ask the current InputStream for data.
 String readLine(Character mask)
          Ask the current InputStream for input, masking keystrokes in the console with the given mask.
 int scan()
          Wait for input.
 void setAnsiSupported(boolean value)
          Controls the shell's usage of ANSI escape code support.
 void setCurrentResource(Resource<?> resource)
          Set the Resource on which the shell should operate.
 void setDefaultPrompt()
          Reset the shell prompt to default.
 void setInputStream(InputStream inputStream)
          Set the stream from which the shell should read input.
 void setOutputStream(OutputStream stream)
          Set the stream to which the shell should print output.
 void setPrompt(String string)
          Set the current shell prompt, followed by '> '.
 void setVerbose(boolean verbose)
          Toggle verbose mode.
 
Methods inherited from interface org.jboss.forge.shell.ShellPrintWriter
print, print, println, println, println, renderColor, write
 
Methods inherited from interface org.jboss.forge.shell.ShellPrompt
prompt, prompt, prompt, prompt, promptAndSwallowCR, promptBoolean, promptBoolean, promptChoice, promptChoice, promptChoice, promptChoiceTyped, promptChoiceTyped, promptCommon, promptCommon, promptCompleter, promptEnum, promptEnum, promptFile, promptFile, promptRegex, promptRegex, promptSecret
 
Methods inherited from interface org.jboss.forge.shell.ShellHistory
setHistory, setHistoryOutputStream, writeToHistory
 

Method Detail

getCurrentDirectory

DirectoryResource getCurrentDirectory()
Return the current working directory resource of the shell. Start with getCurrentResource() and move up the hierarchy until a DirectoryResource is found. (This value may change through execution of plug-ins or other operations.)


getCurrentResource

Resource<?> getCurrentResource()
Return the current working Resource of the shell. (This value may change through execution of plug-ins or other operations.) TODO implement ResourceBag for multiple resources


getCurrentResourceScope

Class<? extends Resource<?>> getCurrentResourceScope()
Return the type of the Resource on which the Shell is currently operating.

See Also:
RequiresResource}

setCurrentResource

void setCurrentResource(Resource<?> resource)
Set the Resource on which the shell should operate.

Note: This may change the current getCurrentDirectory()


getConfigDir

DirectoryResource getConfigDir()
Return the file-system directory currently in use as the configuration directory. (Usually "~/.forge/")


getCurrentProject

Project getCurrentProject()
Return the Project on which this shell instance is currently operating.


isPretend

boolean isPretend()
Return true if this shell is currently running in pretend mode.

Modifications to files made while running in pretend mode are made in a temporary directory, and the output is produced as a Diff that can then be applied to the project.


isVerbose

boolean isVerbose()
Return true if this shell is currently running in verbose mode.


setVerbose

void setVerbose(boolean verbose)
Toggle verbose mode.


printlnVerbose

void printlnVerbose(String output)
Write output to the console, only if isVerbose() == true.


printlnVerbose

void printlnVerbose(ShellColor color,
                    String output)
Write color output to the console, only if isVerbose() == true.


clear

void clear()
Clear the console.


execute

void execute(String command)
Execute a shell command.


execute

void execute(File file)
             throws IOException
Execute a shell script from the specified file.

Throws:
IOException

execute

void execute(File file,
             String... args)
             throws IOException
Execute a shell script from the specified file, passing the given arguments as input.

Throws:
IOException

isExecuting

boolean isExecuting()
Return true if the Shell is currently executing a plugin; otherwise, return false.


scan

int scan()
Wait for input. Return as soon as any key is pressed and return the scancode.


clearLine

void clearLine()
Clear the current line of any text.


cursorLeft

void cursorLeft(int x)
Move the cursor x the specified number of positions.


setDefaultPrompt

void setDefaultPrompt()
Reset the shell prompt to default.


setPrompt

void setPrompt(String string)
Set the current shell prompt, followed by '> '.


getPrompt

String getPrompt()
Return the current shell prompt;


setInputStream

void setInputStream(InputStream inputStream)
                    throws IOException
Set the stream from which the shell should read input.

Throws:
IOException

setOutputStream

void setOutputStream(OutputStream stream)
                     throws IOException
Set the stream to which the shell should print output.

Throws:
IOException

getHeight

int getHeight()
Return the current height, in characters, of the current shell console. (Warning: This may change in the time between when the method is called and when the result is used. Be sure to call the method as close to its actual use as possible.)


getWidth

int getWidth()
Return the current width, in characters, of the current shell console. (Warning: This may change in the time between when the method is called and when the result is used. Be sure to call the method as close to its actual use as possible.)


readLine

String readLine()
                throws IOException
Ask the current InputStream for data.

Returns:
any read data as a string, or null if none available.
Throws:
IOException - on error

readLine

String readLine(Character mask)
                throws IOException
Ask the current InputStream for input, masking keystrokes in the console with the given mask.

Parameters:
mask - The character to use for masking input
Returns:
any read data as a string, or null if none available.
Throws:
IOException - on error

setAnsiSupported

void setAnsiSupported(boolean value)
Controls the shell's usage of ANSI escape code support. This method does not guarantee ANSI will function properly, as the underlying Terminal must also support it.


isAnsiSupported

boolean isAnsiSupported()
Returns whether or not this shell supports ANSI escape codes.


getEnvironment

ForgeEnvironment getEnvironment()
Get the current Forge environment.



Copyright © 2011 Seam Framework. All Rights Reserved.