1 package org.springframework.roo.shell; 2 3 import java.io.File; 4 5 import org.springframework.roo.shell.event.ShellStatusProvider; 6 7 /** 8 * Specifies the contract for an interactive shell. 9 * 10 * <p> 11 * Any interactive shell class which implements these methods can be launched by the roo-bootstrap mechanism. 12 * 13 * <p> 14 * It is envisaged implementations will be provided for JLine initially, with possible implementations for 15 * Eclipse in the future. 16 * 17 * @author Ben Alex 18 * @since 1.0 19 * 20 */ 21 public interface Shell extends ShellStatusProvider, ShellPromptAccessor { 22 23 /** 24 * Presents a console prompt and allows the user to interact with the shell. The shell should not return 25 * to the caller until the user has finished their session (by way of a "quit" or similar command). 26 */ 27 void promptLoop(); 28 29 /** 30 * @return null if no exit was requested, otherwise the last exit code indicated to the shell to use 31 */ 32 ExitShellRequest getExitShellRequest(); 33 34 /** 35 * Runs the specified command. Control will return to the caller after the command is run. 36 * 37 * @param line to execute (required) 38 * @return true if the command was successful, false if there was an exception 39 */ 40 boolean executeCommand(String line); 41 42 /** 43 * Indicates the shell should switch into a lower-level development mode. The exact meaning varies by 44 * shell implementation. 45 * 46 * @param developmentMode true if development mode should be enabled, false otherwise 47 */ 48 void setDevelopmentMode(boolean developmentMode); 49 50 boolean isDevelopmentMode(); 51 52 /** 53 * Changes the "path" displayed in the shell prompt. An implementation will ensure this path is 54 * included on the screen, taking care to merge it with the product name and handle any special 55 * formatting requirements (such as ANSI, if supported by the implementation). 56 * 57 * @param path to set (can be null or empty; must NOT be formatted in any special way eg ANSI codes) 58 */ 59 void setPromptPath(String path); 60 61 /** 62 * Returns the home directory of the current running shell instance 63 * 64 * @return the home directory of the current shell instance 65 */ 66 File getHome(); 67 }