brigadier
brigadier copied to clipboard
Add some quality of life improvements to `StringReader`
Added 2 new useful functions to StringReader
- overload of
StringReader::expect
that accepts a string, and expects the string -
StringReader::expectOption
which expects one of a list of String
There we go. I made all of the requested changes (I hope)
Maybe it would be useful to have a expectOption
overload which accepts some kind of Collection, for example List. Then the current implementation could call it with expectOption(Arrays.asList(opts))
which is not that expensive since the created list is backed by the array.
@Marcono1234 I'm not fond of any options that require you to wrap an array in a collection.
That said, I could see an overload that takes a collection being useful in some situations. My approach would be to make it as generalised as possible, though, so you can take any object you want, not just lists.
String expectOption(final Collection<String> opts);
String expectOption(final String... opts);
expectOption("1", "2", "3");
expectOption(new ArrayList<>());
expectOption(new HashSet<>());
@Dinnerbone Is there anything else I need to change for this to go through?
Closing and reopening to rerun checks.
OOF. I guess we cannot reopen. And we can't rerun checks without doing odd things.
Sorry :(