Search in sources :

Example 1 with Connect

use of edu.umass.cs.gnsclient.console.commands.Connect in project GNS by MobilityFirst.

the class ConsoleModule method handlePrompt.

/**
   * Handle a series of commands
   *
   */
public void handlePrompt() {
    quit = false;
    // Try to connect to the GNS
    try {
        new Connect(this).parse("");
    } catch (Exception e) {
        printString("Couldn't connect to GNS...\n");
    }
    if (useGnsDefaults) {
        useGnsDefaults();
    }
    while (!quit) {
        Map<String, ConsoleCommand> hashCommands = getHashCommands();
        try {
            String commandLine;
            if (silent) {
                console.flushConsole();
                commandLine = readLineBypassJLine();
            } else {
                commandLine = console.readLine(getPromptString());
            }
            if (commandLine == null) {
                quit();
                break;
            }
            if (commandLine.equals("")) {
                continue;
            }
            handleCommandLine(commandLine, hashCommands);
        } catch (UnknownCommandException e) {
            printString(e.getMessage() + "\n");
        } catch (Exception e) {
            printString("Error during console command execution: " + e.getMessage() + "\n");
            e.printStackTrace();
        }
    }
    GNSClientConfig.getLogger().fine("Quitting");
}
Also used : Connect(edu.umass.cs.gnsclient.console.commands.Connect) ConsoleCommand(edu.umass.cs.gnsclient.console.commands.ConsoleCommand) JSONException(org.json.JSONException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Connect (edu.umass.cs.gnsclient.console.commands.Connect)1 ConsoleCommand (edu.umass.cs.gnsclient.console.commands.ConsoleCommand)1 ClientException (edu.umass.cs.gnscommon.exceptions.client.ClientException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 JSONException (org.json.JSONException)1