@Override
  public int run(String[] argv) throws Exception {
    int exitCode = 0;

    Options options = buildOptions();
    if(argv.length == 0) {
      printHelp();
      return -1;
    }

    CommandLineParser parser = new PosixParser();
    CommandLine cmd;

    try {
      cmd = parser.parse(options, argv);
    } catch (ParseException e) {
      System.out.println(
        "Error parsing command-line options: " + e.getMessage());
      printHelp();
      return -1;
    }

    if(cmd.hasOption("h")) { // print help and exit
      printHelp();
      return -1;
    }

    boolean printToScreen    = false;
    String inputFilenameArg  = cmd.getOptionValue("i");
    String outputFilenameArg = cmd.getOptionValue("o");
    String processor         = cmd.getOptionValue("p");
    if(processor == null) { processor = defaultProcessor; }

    if(cmd.hasOption("v")) { // print output to screen too
      printToScreen = true;
      System.out.println("input  [" + inputFilenameArg  + "]");
      System.out.println("output [" + outputFilenameArg + "]");
    }

    try {
      go(EditsVisitorFactory.getEditsVisitor(
        outputFilenameArg,
        processor,
        TokenizerFactory.getTokenizer(inputFilenameArg),
        printToScreen));
    } catch (EOFException e) {
      System.err.println("Input file ended unexpectedly. Exiting");
      exitCode = 255;
    } catch(IOException e) {
      System.err.println("Encountered exception. Exiting: " + e.getMessage());
      exitCode = 1;
    }

    return exitCode;
  }
@ Override public int run ( String [ ] argv ) throws Exception { int exitCode = 0 ; Options options = buildOptions ( ) ; if ( argv . length == 0 ) { printHelp ( ) ; return - 1 ; } CommandLineParser parser = new PosixParser ( ) ; CommandLine cmd ; try { cmd = parser . parse ( options , argv ) ; } catch ( ParseException e ) { System . out . println ( "Error parsing command-line options: " + e . getMessage ( ) ) ; printHelp ( ) ; return - 1 ; } if ( cmd . hasOption ( "h" ) ) { printHelp ( ) ; return - 1 ; } boolean printToScreen = false ; String inputFilenameArg = cmd . getOptionValue ( "i" ) ; String outputFilenameArg = cmd . getOptionValue ( "o" ) ; String processor = cmd . getOptionValue ( "p" ) ; if ( processor == null ) { processor = defaultProcessor ; } if ( cmd . hasOption ( "v" ) ) { printToScreen = true ; System . out . println ( "input  [" + inputFilenameArg + "]" ) ; System . out . println ( "output [" + outputFilenameArg + "]" ) ; } try { go ( EditsVisitorFactory . getEditsVisitor ( outputFilenameArg , processor , TokenizerFactory . getTokenizer ( inputFilenameArg ) , printToScreen ) ) ; } catch ( EOFException e ) { System . err . println ( "Input file ended unexpectedly. Exiting" ) ; exitCode = 255 ; } catch ( IOException e ) { System . err . println ( "Encountered exception. Exiting: " + e . getMessage ( ) ) ; exitCode = 1 ; } return exitCode ; }
Main entry point for ToolRunner (see ToolRunner docs)

@param argv The parameters passed to this program.
@return 0 on success, non zero on error.