public void handle()

in api-reference-examples/java/te-tag-query/com/facebook/threatexchange/TETagQuery.java [431:500]


    public void handle(
      String[] args,
      int numIDsPerQuery,
      boolean verbose,
      boolean showURLs,
      DescriptorFormatter descriptorFormatter
    ) {
      boolean includeIndicatorInOutput = true;
      String dataDir = null;

      while (args.length > 0 && args[0].startsWith("-")) {
        String option = args[0];
        args = Arrays.copyOfRange(args, 1, args.length);

        if (option.equals("-h") || option.equals("--help")) {
          usage(0);

        } else if (option.equals("--data-dir")) {
          if (args.length < 1) {
            usage(1);
          }
          dataDir = args[0];
          args = Arrays.copyOfRange(args, 1, args.length);

        } else if (option.equals("--no-print-indicator")) {
          includeIndicatorInOutput = false;

        } else {
          System.err.printf("%s %s: unrecognized option \"%s\".\n",
            PROGNAME, _verb, option);
          usage(1);
        }
      }

      if (dataDir != null) {
        File handle = new File(dataDir);
        boolean ok = handle.exists() || handle.mkdirs();
        if (!ok) {
          System.err.printf("%s: could not create output directory \"%s\"\n",
            PROGNAME, dataDir);
          System.exit(1);
        }
      }

      List<String> ids = new ArrayList<String>();

      if (args.length > 0) {
        for (String arg: args) {
          ids.add(arg);
        }
      } else {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line;
        int lno = 1;
        try {
          while ((line = reader.readLine()) != null) {
            lno++;
            // In Java, line-terminators already stripped for us
            ids.add(line);
          }
        } catch (IOException e) {
          System.err.printf("Couldn't read line %d of standard input.\n", lno);
          System.exit(1);
        }
      }

      outputDetails(ids, numIDsPerQuery, verbose, showURLs,
        IndicatorTypeFilterer.createAllFilterer(), includeIndicatorInOutput,
        dataDir, descriptorFormatter);
    }