@Override
    public ResultModel preExecution(GfshParseResult parseResult) {
      String dir = parseResult.getParamValueAsString("dir");
      if (StringUtils.isBlank(dir)) {
        saveDirFile = new File(".").getAbsoluteFile();
        return new ResultModel();
      }

      saveDirFile = new File(dir.trim()).getAbsoluteFile();

      if (!saveDirFile.exists() && !saveDirFile.mkdirs()) {
        return ResultModel
            .createError(CliStrings.format(CliStrings.EXPORT_CONFIG__MSG__CANNOT_CREATE_DIR, dir));
      }

      if (!saveDirFile.isDirectory()) {
        return ResultModel
            .createError(CliStrings.format(CliStrings.EXPORT_CONFIG__MSG__NOT_A_DIRECTORY, dir));
      }

      try {
        if (!saveDirFile.canWrite()) {
          return ResultModel.createError(CliStrings.format(
              CliStrings.EXPORT_CONFIG__MSG__NOT_WRITEABLE, saveDirFile.getCanonicalPath()));
        }
      } catch (IOException ioex) {
        return ResultModel.createError(
            CliStrings.format(CliStrings.EXPORT_CONFIG__MSG__NOT_WRITEABLE, saveDirFile.getName()));
      }
      return new ResultModel();
    }
Interceptor used by gfsh to intercept execution of export config command at "shell".
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/ExportConfigCommand.java