|
|
|
|
@@ -43,8 +43,6 @@ import java.util.List;
|
|
|
|
|
import java.util.logging.Level;
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
|
|
import fr.bigeon.gclc.command.ExitCommand;
|
|
|
|
|
import fr.bigeon.gclc.command.HelpExecutor;
|
|
|
|
|
import fr.bigeon.gclc.command.ICommand;
|
|
|
|
|
import fr.bigeon.gclc.command.ICommandProvider;
|
|
|
|
|
import fr.bigeon.gclc.command.SubedCommand;
|
|
|
|
|
@@ -54,7 +52,6 @@ import fr.bigeon.gclc.exception.CommandRunExceptionType;
|
|
|
|
|
import fr.bigeon.gclc.exception.InvalidCommandName;
|
|
|
|
|
import fr.bigeon.gclc.i18n.Messages;
|
|
|
|
|
import fr.bigeon.gclc.manager.ConsoleManager;
|
|
|
|
|
import fr.bigeon.gclc.manager.SystemConsoleManager;
|
|
|
|
|
|
|
|
|
|
/** <p>
|
|
|
|
|
* A {@link ConsoleApplication} is an application that require the user to input
|
|
|
|
|
@@ -63,7 +60,8 @@ import fr.bigeon.gclc.manager.SystemConsoleManager;
|
|
|
|
|
* A typical use case is the following:
|
|
|
|
|
*
|
|
|
|
|
* <pre>
|
|
|
|
|
* {@link ConsoleApplication} app = new {@link ConsoleApplication#ConsoleApplication(String, String, String) ConsoleApplication("exit", "welcome", "see you latter")};
|
|
|
|
|
* {@link ConsoleManager} manager = new {@link fr.bigeon.gclc.manager.SystemConsoleManager#SystemConsoleManager()}
|
|
|
|
|
* {@link ConsoleApplication} app = new {@link ConsoleApplication#ConsoleApplication(ConsoleManager, String, String) ConsoleApplication(manager, "welcome", "see you latter")};
|
|
|
|
|
* app.{@link ConsoleApplication#add(ICommand) add}("my_command", new {@link ICommand MyCommand()});
|
|
|
|
|
* app.{@link ConsoleApplication#start start}();
|
|
|
|
|
* </pre>
|
|
|
|
|
@@ -103,54 +101,11 @@ public class ConsoleApplication implements ICommandProvider {
|
|
|
|
|
root = new SubedCommand(""); //$NON-NLS-1$
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @param manager the manager
|
|
|
|
|
* @param exit the keyword for the exit command of this application
|
|
|
|
|
* @param welcome the header message to display on launch of this
|
|
|
|
|
* application
|
|
|
|
|
* @param goodbye the message to display on exit
|
|
|
|
|
* @throws InvalidCommandName if the exit command name is invalid
|
|
|
|
|
* @deprecated since 1.2.0, use the {@link #add(ICommand)} method to add the
|
|
|
|
|
* exit command */
|
|
|
|
|
@Deprecated
|
|
|
|
|
public ConsoleApplication(ConsoleManager manager, String exit,
|
|
|
|
|
String welcome, String goodbye) throws InvalidCommandName {
|
|
|
|
|
this(manager, welcome, goodbye);
|
|
|
|
|
root.add(new ExitCommand(exit, this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @param exit the keyword for the exit command of this application
|
|
|
|
|
* @param welcome the header message to display on launch of this
|
|
|
|
|
* application
|
|
|
|
|
* @param goodbye the message to display on exit
|
|
|
|
|
* @throws InvalidCommandName if the exit command name is invalid
|
|
|
|
|
* @deprecated since 1.2.0, use the {@link #add(ICommand)} method to add the
|
|
|
|
|
* command and create this console using the
|
|
|
|
|
* {@link #ConsoleApplication(ConsoleManager, String, String)}
|
|
|
|
|
* method with a {@link SystemConsoleManager} as argument */
|
|
|
|
|
@Deprecated
|
|
|
|
|
public ConsoleApplication(String exit, String welcome,
|
|
|
|
|
String goodbye) throws InvalidCommandName {
|
|
|
|
|
this(new SystemConsoleManager(), welcome, goodbye);
|
|
|
|
|
root.add(new ExitCommand(exit, this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public final boolean add(ICommand cmd) throws InvalidCommandName {
|
|
|
|
|
return root.add(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Adds help command on the given key
|
|
|
|
|
*
|
|
|
|
|
* @param cmd the handle for help
|
|
|
|
|
* @return if the help command was added
|
|
|
|
|
* @throws InvalidCommandName if the help command was not valid
|
|
|
|
|
* @deprecated since 1.2.0 use the {@link #add(ICommand)} with a
|
|
|
|
|
* {@link HelpExecutor} instead */
|
|
|
|
|
@Deprecated
|
|
|
|
|
public final boolean addHelpCommand(String cmd) throws InvalidCommandName {
|
|
|
|
|
return root.add(new HelpExecutor(cmd, manager, root));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Add a command request listener.
|
|
|
|
|
* <p>
|
|
|
|
|
* A listener can listen several times to the same application.
|
|
|
|
|
|