Community
Participate
Working Groups
If using whitespace after "-p" the parameter name and value contains those values. Therefore these values should be trimmed. See Mwe2Launcher, lines 64/65 String name = string.substring(0, index); String value = string.substring(index + 1); Change to: String name = string.substring(0, index).trim(); String value = string.substring(index + 1).trim(); See class WorkflowRunner, line 265 params.put(string[0], string[1]); Change to: params.put(string[0].trim(), string[1].trim());
Spaces usually seperate command line args while name=value is exactly one arg. Furthermore I can imagine clients who actually want to pass a single space or a tab as an argument e.g. to affect the indentation of the generated code. As the docs are clear about name=value instead of name = value I'd like to close this as won't fix.
I tried -p a=x b="foo bar" and got two params a and b (no white space) and the expected values as well. I tried -p a = x and the command line parser interprets them as three parameters. What scenario did you tried, which didn't result in what you'd expected?
I have created a line "-p <key>=<value>" and passed that one to the main method. The parameter key was interpreted with whitespace in front, so instead of having a parameter "<key>" the parameter name is " <key>". I had to make the line to "-p<key>=<value>" to get it work. Although the docs state "<key>=<value>" they do not make a hint that after "-p" there must be no space. The command line help even hints to add the space. -p, --param <key>=<value> external property .... I think it should work both with leading space or without. If you want to pass whitespace explicitly as argument you always have the option to quote that, and this would even the better way to express it on the command-line.
Java splits and trims the command line, so that "-p foo=bar" becomes two entries in the passed array. The API is explaining the command line interface and it is not meant to be called directly from Java. You can do so, though, but I don't want to add splitting and trimming to the passed String[] in order to make it more forgiving. I tried to make the Mwe2Launcher as thin as possible, such that it acts as a command line facade only. You should instead use the programming API which is Mwe2Runner.