@Override
  public Properties getEnvironmentVariables(Platform platform, OptionsByType optionsByType) {
    Table diagnosticsTable = optionsByType.get(Table.class);
    EnvironmentVariables environmentVariables =
        optionsByType.getOrSetDefault(
            EnvironmentVariables.class,
            EnvironmentVariables.of(EnvironmentVariables.Source.TargetPlatform));

    Properties variables = new Properties();

    switch (environmentVariables.getSource()) {
      case Custom:
        if (diagnosticsTable != null) {
          diagnosticsTable.addRow("Environment Variables", "(cleared)");
        }

        break;

      case ThisApplication:
        variables.putAll(System.getenv());

        if (diagnosticsTable != null) {
          diagnosticsTable.addRow("Environment Variables", "(based on parent process)");
        }

        break;

      case TargetPlatform:
        if (diagnosticsTable != null) {
          diagnosticsTable.addRow("Environment Variables", "(based on platform defaults)");
        }

        break;
    }

    // add the optionally defined environment variables
    variables.putAll(environmentVariables.realize(platform, optionsByType.asArray()));

    if (variables.size() > 0 && diagnosticsTable != null) {
      Table table = Tabularize.tabularize(variables);

      diagnosticsTable.addRow("", table.toString());
    }

    return variables;
  }