-
-
Notifications
You must be signed in to change notification settings - Fork 75
Closed
Labels
enhancementNew feature or requestNew feature or requestimplemented for next releaseThis has been implemented in the current dev build for the next public releaseThis has been implemented in the current dev build for the next public release
Description
Description
Basically:
/command arg1 arg2 Text1="Something" Text2="Something123" Foo="Bar"
I would expect arg1 and arg2 to behave normally, while the map argument itself to return a Map<String, String> (or whatever key / value object I would want it to parse)
In this example I'd expect the Map to be filled with:
Text -> Something
Text2 -> Something123
Foo -> Bar
Expected code
Example code (Barely functional):
public class MapArgument<K, V> extends CustomArgument<Map<K, V>, String> {
protected MapArgument(String nodeName, Function<String, K> keyParser, Function<String, V> valueParser) {
super(new GreedyStringArgument(nodeName), (info) -> {
Map<K, V> arguments = new HashMap<>();
String[] pairs = info.input().split(" ");
for (String pair : pairs) {
int splitter = pair.indexOf('=');
if (pair.length() == splitter + 1) continue;
K key = keyParser.apply(pair.substring(0, splitter));
V value = valueParser.apply(pair.substring(splitter + 1));
arguments.put(key, value);
}
return arguments;
});
}
}Extra details
Original message:
https://discord.com/channels/745416925924032523/745757702608912556/1061681316610973706
willkroboth
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestimplemented for next releaseThis has been implemented in the current dev build for the next public releaseThis has been implemented in the current dev build for the next public release