private static Path getCodegenDir(CommandLine line) {

    if (!line.hasOption(CODEGEN)
        && (!line.hasOption(SHOW_VALUES) && !line.hasOption(OUTPUT_MODEL))) {
      printHelp(configureOptions());
      System.exit(1);
    }

    if (line.hasOption(CODEGEN)) {

      File codegenDir = new File(line.getOptionValue(CODEGEN));
      if (codegenDir.exists()) {
        if (!codegenDir.canWrite()) {
          System.err.println("Codegen '" + codegenDir + "' is not writable");
          System.exit(1);
        } else if (!codegenDir.isDirectory()) {
          System.err.println("Codegen '" + codegenDir + "' is not a directory");
          System.exit(1);
        }
      }
      return codegenDir.toPath();
    } else {
      return null;
    }
  }