Buggy code:
public final class VectorDumper { private static final Logger log = LoggerFactory . getLogger ( VectorDumper . class ) ; private VectorDumper ( ) { } public static void main ( String [ ] args ) throws IOException { DefaultOptionBuilder obuilder = new DefaultOptionBuilder ( ) ; ArgumentBuilder abuilder = new ArgumentBuilder ( ) ; GroupBuilder gbuilder = new GroupBuilder ( ) ; Option seqOpt = obuilder . withLongName ( "seqFile" ) . withRequired ( false ) . withArgument ( abuilder . withName ( "seqFile" ) . withMinimum ( 1 ) . withMaximum ( 1 ) . create ( ) ) . withDescription ( "The<seq2seq4repair_space>Sequence<seq2seq4repair_space>File<seq2seq4repair_space>containing<seq2seq4repair_space>the<seq2seq4repair_space>Vectors" ) . withShortName ( "s" ) . create ( ) ; Option vectorAsKeyOpt = obuilder . withLongName ( "useKey" ) . withRequired ( false ) . withDescription ( "If<seq2seq4repair_space>the<seq2seq4repair_space>Key<seq2seq4repair_space>is<seq2seq4repair_space>a<seq2seq4repair_space>vector,<seq2seq4repair_space>then<seq2seq4repair_space>dump<seq2seq4repair_space>that<seq2seq4repair_space>instead" ) . withShortName ( "u" ) . create ( ) ; Option printKeyOpt = obuilder . withLongName ( "printKey" ) . withRequired ( false ) . withDescription ( "Print<seq2seq4repair_space>out<seq2seq4repair_space>the<seq2seq4repair_space>key<seq2seq4repair_space>as<seq2seq4repair_space>well,<seq2seq4repair_space>delimited<seq2seq4repair_space>by<seq2seq4repair_space>a<seq2seq4repair_space>tab<seq2seq4repair_space>(or<seq2seq4repair_space>the<seq2seq4repair_space>value<seq2seq4repair_space>if<seq2seq4repair_space>useKey<seq2seq4repair_space>is<seq2seq4repair_space>true)" ) . withShortName ( "p" ) . create ( ) ; Option outputOpt = obuilder . withLongName ( "output" ) . withRequired ( false ) . withArgument ( abuilder . withName ( "output" ) . withMinimum ( 1 ) . withMaximum ( 1 ) . create ( ) ) . withDescription ( "The<seq2seq4repair_space>output<seq2seq4repair_space>file.<seq2seq4repair_space>If<seq2seq4repair_space>not<seq2seq4repair_space>specified,<seq2seq4repair_space>dumps<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>console" ) . withShortName ( "o" ) . create ( ) ; Option dictOpt = obuilder . withLongName ( "dictionary" ) . withRequired ( false ) . withArgument ( abuilder . withName ( "dictionary" ) . withMinimum ( 1 ) . withMaximum ( 1 ) . create ( ) ) . withDescription ( "The<seq2seq4repair_space>dictionary<seq2seq4repair_space>file.<seq2seq4repair_space>" ) . withShortName ( "d" ) . create ( ) ; Option dictTypeOpt = obuilder . withLongName ( "dictionaryType" ) . withRequired ( false ) . withArgument ( abuilder . withName ( "dictionaryType" ) . withMinimum ( 1 ) . withMaximum ( 1 ) . create ( ) ) . withDescription ( "The<seq2seq4repair_space>dictionary<seq2seq4repair_space>file<seq2seq4repair_space>type<seq2seq4repair_space>(text|sequencefile)" ) . withShortName ( "dt" ) . create ( ) ; Option centroidJSonOpt = obuilder . withLongName ( "json" ) . withRequired ( false ) . withDescription ( "Output<seq2seq4repair_space>the<seq2seq4repair_space>centroid<seq2seq4repair_space>as<seq2seq4repair_space>JSON.<seq2seq4repair_space>Otherwise<seq2seq4repair_space>it<seq2seq4repair_space>substitutes<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>terms<seq2seq4repair_space>for<seq2seq4repair_space>vector<seq2seq4repair_space>cell<seq2seq4repair_space>entries" ) . withShortName ( "j" ) . create ( ) ; <START_BUG> Option sizeOpt = obuilder . withLongName ( "sizeOnly" ) . withRequired ( true ) . withDescription ( "Dump<seq2seq4repair_space>only<seq2seq4repair_space>the<seq2seq4repair_space>size<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>vector" ) . withShortName ( "sz" ) . create ( ) ; <END_BUG> Option helpOpt = obuilder . withLongName ( "help" ) . withDescription ( "Print<seq2seq4repair_space>out<seq2seq4repair_space>help" ) . withShortName ( "h" ) . create ( ) ; Group group = gbuilder . withName ( "Options" ) . withOption ( seqOpt ) . withOption ( outputOpt ) . withOption ( dictTypeOpt ) . withOption ( dictOpt ) . withOption ( centroidJSonOpt ) . withOption ( vectorAsKeyOpt ) . withOption ( printKeyOpt ) . withOption ( sizeOpt ) . create ( ) ; try { Parser parser = new Parser ( ) ; parser . setGroup ( group ) ; CommandLine cmdLine = parser . parse ( args ) ; if ( cmdLine . hasOption ( helpOpt ) ) { VectorDumper . printHelp ( group ) ; return ; } if ( cmdLine . hasOption ( seqOpt ) ) { Path path = new Path ( cmdLine . getValue ( seqOpt ) . toString ( ) ) ; Configuration conf = new Configuration ( ) ; FileSystem fs = FileSystem . get ( path . toUri ( ) , conf ) ; String dictionaryType = "text" ; if ( cmdLine . hasOption ( dictTypeOpt ) ) { dictionaryType = cmdLine . getValue ( dictTypeOpt ) . toString ( ) ; } String [ ] dictionary = null ; if ( cmdLine . hasOption ( dictOpt ) ) { if ( "text" . equals ( dictionaryType ) ) { dictionary = VectorHelper . loadTermDictionary ( new File ( cmdLine . getValue ( dictOpt ) . toString ( ) ) ) ; } else if ( "sequencefile" . equals ( dictionaryType ) ) { dictionary = VectorHelper . loadTermDictionary ( conf , fs , cmdLine . getValue ( dictOpt ) . toString ( ) ) ; } else { throw new OptionException ( dictTypeOpt ) ; } } boolean useJSON = cmdLine . hasOption ( centroidJSonOpt ) ; boolean sizeOnly = cmdLine . hasOption ( sizeOpt ) ; SequenceFile . Reader reader = new SequenceFile . Reader ( fs , path , conf ) ; try { Iterable < Vector > vectorIterable = new SequenceFileVectorIterable ( reader , cmdLine . hasOption ( vectorAsKeyOpt ) ) ; Writer writer = ( cmdLine . hasOption ( outputOpt ) ) ? new FileWriter ( cmdLine . getValue ( outputOpt ) . toString ( ) ) : new OutputStreamWriter ( System . out ) ; try { boolean printKey = cmdLine . hasOption ( printKeyOpt ) ; SeqFileIterator iterator = ( ( SeqFileIterator ) ( vectorIterable . iterator ( ) ) ) ; long i = 0 ; while ( iterator . hasNext ( ) ) { Vector vector = iterator . next ( ) ; if ( printKey ) { writer . write ( iterator . key ( ) . toString ( ) ) ; writer . write ( "\t" ) ; } if ( sizeOnly == false ) { String fmtStr = ( useJSON ) ? vector . asFormatString ( ) : VectorHelper . vectorToString ( vector , dictionary ) ; writer . write ( fmtStr ) ; writer . write ( '\n' ) ; } else { if ( vector instanceof NamedVector ) { writer . write ( ( ( NamedVector ) ( vector ) ) . getName ( ) ) ; writer . write ( ":" ) ; } else { writer . write ( String . valueOf ( ( i ++ ) ) ) ; writer . write ( ":" ) ; } writer . write ( String . valueOf ( vector . size ( ) ) ) ; writer . write ( '\n' ) ; } } }

Fix:
Option sizeOpt = obuilder . withLongName ( "sizeOnly" ) . withRequired ( false ) . withDescription ( "Dump<seq2seq4repair_space>only<seq2seq4repair_space>the<seq2seq4repair_space>size<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>vector" ) . withShortName ( "sz" ) . create ( ) ;