@Test public void test2() throws ParseException { Options options = new Options().addOption( "o", "opt", false, "desc" ); String[] args = { "--opt", "--unknown" }; CommandLine commandLine = this.parser.parse( options, args ); Assert.assertEquals( 1, commandLine.getOptions().length ); }
@Override public CommandLine parse( final Options options, final String[] arguments, final Properties properties, final boolean stopAtNonOption ) throws ParseException { List<String> argumentList = new ArrayList<>( Arrays.asList( arguments ) ); CommandLine parse = null; while ( parse == null && !argumentList.isEmpty() ) { try { String[] argumentListArray = argumentList.toArray( new String[0] ); parse = super.parse( options, argumentListArray, properties, false ); } catch ( UnrecognizedOptionException ex ) { argumentList.remove( ex.getOption() ); } } if ( parse == null ) { parse = super.parse( options, new String[0], properties, false ); } return parse; }
IgnoreUnknownParser extends DefaultParser { @Override public CommandLine parse( final Options options, final String[] arguments, final Properties properties, final boolean stopAtNonOption ) throws ParseException { List<String> argumentList = new ArrayList<>( Arrays.asList( arguments ) ); CommandLine parse = null; while ( parse == null && !argumentList.isEmpty() ) { try { String[] argumentListArray = argumentList.toArray( new String[0] ); parse = super.parse( options, argumentListArray, properties, false ); } catch ( UnrecognizedOptionException ex ) { argumentList.remove( ex.getOption() ); } } if ( parse == null ) { parse = super.parse( options, new String[0], properties, false ); } return parse; } }
IgnoreUnknownParser extends DefaultParser { @Override public CommandLine parse( final Options options, final String[] arguments, final Properties properties, final boolean stopAtNonOption ) throws ParseException { List<String> argumentList = new ArrayList<>( Arrays.asList( arguments ) ); CommandLine parse = null; while ( parse == null && !argumentList.isEmpty() ) { try { String[] argumentListArray = argumentList.toArray( new String[0] ); parse = super.parse( options, argumentListArray, properties, false ); } catch ( UnrecognizedOptionException ex ) { argumentList.remove( ex.getOption() ); } } if ( parse == null ) { parse = super.parse( options, new String[0], properties, false ); } return parse; }  }
IgnoreUnknownParser extends DefaultParser { @Override public CommandLine parse( final Options options, final String[] arguments, final Properties properties, final boolean stopAtNonOption ) throws ParseException { List<String> argumentList = new ArrayList<>( Arrays.asList( arguments ) ); CommandLine parse = null; while ( parse == null && !argumentList.isEmpty() ) { try { String[] argumentListArray = argumentList.toArray( new String[0] ); parse = super.parse( options, argumentListArray, properties, false ); } catch ( UnrecognizedOptionException ex ) { argumentList.remove( ex.getOption() ); } } if ( parse == null ) { parse = super.parse( options, new String[0], properties, false ); } return parse; }  @Override CommandLine parse( final Options options, final String[] arguments, final Properties properties,
        final boolean stopAtNonOption ); }
IgnoreUnknownParser extends DefaultParser { @Override public CommandLine parse( final Options options, final String[] arguments, final Properties properties, final boolean stopAtNonOption ) throws ParseException { List<String> argumentList = new ArrayList<>( Arrays.asList( arguments ) ); CommandLine parse = null; while ( parse == null && !argumentList.isEmpty() ) { try { String[] argumentListArray = argumentList.toArray( new String[0] ); parse = super.parse( options, argumentListArray, properties, false ); } catch ( UnrecognizedOptionException ex ) { argumentList.remove( ex.getOption() ); } } if ( parse == null ) { parse = super.parse( options, new String[0], properties, false ); } return parse; }  @Override CommandLine parse( final Options options, final String[] arguments, final Properties properties,
        final boolean stopAtNonOption );  }