question: public static HashMap < String , String > parseArgs ( String [ ] args ) { HashMap < String , String > parsedArgs = new HashMap < > ( ) ; boolean lookingForValue = false ; String currentKey = null ; for ( String arg : args ) { Pattern argKeyPattern = Pattern . compile ( "^-[a-zA-Z]\\S+" ) ; Matcher argKey = argKeyPattern . matcher ( arg ) ; if ( argKey . find ( ) ) { if ( lookingForValue ) { parsedArgs . put ( currentKey , "" ) ; } currentKey = arg . substring ( 1 ) ; lookingForValue = true ; } else { if ( lookingForValue ) { parsedArgs . put ( currentKey , arg ) ; lookingForValue = false ; } } } if ( lookingForValue && currentKey != null ) { parsedArgs . put ( currentKey , "" ) ; } return parsedArgs ; }
target:  Parses the arguments passed to a feature function in the Joshua config file TODO: Replace this with a proper CLI library at some point Expects key value pairs in the form : -argname value Any key without a value is added with an empty string as value Multiple values for the same key are not parsed. The first one is used.