private int parseOptions(final String... args) {
    OptionSet parsedOptions;
    try {
      parsedOptions = commandLineParser.parse(args);
    } catch (OptionException e) {
      System.err.println(
          CliStrings.format(MSG_INVALID_COMMAND_OR_OPTION, StringUtils.join(args, SEPARATOR)));
      return ExitShellRequest.FATAL_EXIT.getExitCode();
    }
    boolean launchShell = true;
    boolean onlyPrintUsage = parsedOptions.has(HELP_OPTION);
    if (parsedOptions.has(EXECUTE_OPTION) || onlyPrintUsage) {
      launchShell = false;
    }

    Gfsh gfsh = null;
    try {
      gfsh = Gfsh.getInstance(launchShell, args, new GfshConfig());
      startupTimeLogHelper.logStartupTime();
    } catch (IllegalStateException isex) {
      System.err.println("ERROR : " + isex.getMessage());
    }

    ExitShellRequest exitRequest = ExitShellRequest.NORMAL_EXIT;

    if (gfsh != null) {
      try {
        if (launchShell) {
          gfsh.start();
          gfsh.waitForComplete();
          exitRequest = gfsh.getExitShellRequest();
        } else if (onlyPrintUsage) {
          printUsage(gfsh, System.out);
        } else {
          @SuppressWarnings("unchecked")
          List<String> commandsToExecute = (List<String>) parsedOptions.valuesOf(EXECUTE_OPTION);

          // Execute all of the commands in the list, one at a time.
          for (int i = 0; i < commandsToExecute.size()
              && exitRequest == ExitShellRequest.NORMAL_EXIT; i++) {
            String command = commandsToExecute.get(i);
            // sanitize the output string to not show the password
            System.out.println(GfshParser.LINE_SEPARATOR + "(" + (i + 1) + ") Executing - "
                + ArgumentRedactor.redact(command) + GfshParser.LINE_SEPARATOR);
            if (!gfsh.executeScriptLine(command) || gfsh.getLastExecutionStatus() != 0) {
              exitRequest = ExitShellRequest.FATAL_EXIT;
            }
          }
        }
      } catch (InterruptedException iex) {
        log(iex, gfsh);
      }
    }

    return exitRequest.getExitCode();
  }
Launcher class for :
<ul>
<li>gfsh 7.0
<li>server
<li>locator
<li>Tools (Pulse, VSD, JConsole, JVisualVM)
<li>Running Command Line Interface (CLI) Commands from OS prompt like
<ol>
<li>
<ul>
<li>compact offline-disk-store - Compact an offline disk store. If the disk store is large,
additional memory may need to be allocated to the process using the --J=-Xmx??? parameter.
<li>describe offline-disk-store - Display information about an offline disk store.
<li>encrypt password - Encrypt a password for use in data source configuration.
<li>run - Execute a set of GFSH commands. Commands that normally prompt for additional input will
instead use default values.
<li>start jconsole - Start the JDK's JConsole tool in a separate process. JConsole will be
launched, but connecting to GemFire must be done manually.
<li>start jvisualvm - Start the JDK's Java VisualVM (jvisualvm) tool in a separate process. Java
VisualVM will be launched, but connecting to GemFire must be done manually.
<li>start locator - Start a Locator.
<li>start pulse - Open a new window in the default Web browser with the URL for the Pulse
application.
<li>start server - Start a GemFire Cache Server.
<li>start vsd - Start VSD in a separate process.
<li>status locator - Display the status of a Locator. Possible statuses are: started, online,
offline or not responding.
<li>status server - Display the status of a GemFire Cache Server.
<li>stop locator - Stop a Locator.
<li>stop server - Stop a GemFire Cache Server.
<li>validate offline-disk-store - Scan the contents of a disk store to verify that it has no
errors.
<li>version - Display product version information.
</ul>
</li>
<li>multiple commands specified using an option "-e"
</ol>
</ul>

@since GemFire 7.0
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/Launcher.java