Closed jontejj closed 11 years ago
This could be implemented in client code as:
Map<Object, Object> map = Arguments.withParser(new ObjectParser()).names("-D")
.asKeyValuesWithKeyParser(new ObjectParser())
.defaultValueSupplier(new Supplier<Map<Object, Object>>(){
@Override
public Map<Object, Object> get()
{
return System.getProperties();
}
})
.parse("-Dsys.prop.test=foo");
assertThat(map.get("sys.prop.test")).isEqualTo("foo");
assertThat(System.getProperty("sys.prop.test")).isEqualTo("foo");
Where ObjectParser would be trivial:
public class ObjectParser implements StringParser<Object>
{
@Override
public Object parse(String argument, Locale locale) throws ArgumentException
{
return argument;
}
...
Where custom [limiters](http://softhouse.github.io/jargo/javadoc/jargo/se/softhouse/jargo/ArgumentBuilder.html#limitTo(com.google.common.base.Predicate) for different keys could be set.
Dismissing this issue as it's not impossible to implement in client code and wouldn't give that much?
Right now this is supported: java -Dproperty=value program But this: java program -Dproperty=value could be supported as well
It would essentially be a Arguments.stringArgument("-D").asPropertyMap().build() put into all command line parsers.