private static String[] parseCommandLine(final String[] args) {
    var flags =
        new Options()
            .addOption(HELP)
            .addOption(CONSOLE_LOGGING)
            .addOption(FILE_LOGGING)
            .addOption(DEBUG_MENU);
    CommandLine cmd;
    String[] positional;
    try {
      cmd = new DefaultParser().parse(flags, args);
      positional = cmd.getArgs();
      if (positional.length > 1) {
        throw new ParseException("More than one workspace file specified");
      }
    } catch (ParseException e) {
      logger.atWarning().withCause(e).log("Invalid command line arguments");
      return null;
    }

    if (cmd.hasOption(HELP.getLongOpt())) {
      new HelpFormatter().printHelp("bindiff --ui [OPTION]... [WORKSPACE]", flags);
      System.exit(0);
    }

    if (cmd.hasOption(CONSOLE_LOGGING.getLongOpt())) {
      Logger.setConsoleLogging(true);
    }
    if (cmd.hasOption(FILE_LOGGING.getLongOpt())) {
      try {
        String logDir = cmd.getOptionValue(FILE_LOGGING.getLongOpt());
        Logger.setFileHandler(
            new FileHandler(logDir.isEmpty() ? Logger.getDefaultLoggingDirectoryPath() : logDir));
        Logger.setFileLogging(true);
      } catch (IOException e) {
        logger.atWarning().withCause(e).log("Could not create log file handler");
      }
    }

    if (cmd.hasOption(DEBUG_MENU.getLongOpt())) {
      Config.getInstance().getPreferencesBuilder().getDebugBuilder().setShowDebugMenu(true);
    }

    return positional;
  }
Parses command line arguments.

@param args the arguments, as passed into {@link #main(String[])}.
@return a list of positional arguments without any options or {@code null} on error.
java/ui/src/main/java/com/google/security/zynamics/bindiff/BinDiff.java