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;
}

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 ; }
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 .
