-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NOVA-Commands Implementation #1
base: master
Are you sure you want to change the base?
Conversation
Minecraft's arguments are for commands are pretty basic, I'd support some version of named arguments at least, like in the form of GNU's getopt:
The natural representation of that would be a hash map. Arguments could be handled by an argument parser that verifies the supplied arguments, and parses them once and not on every access. Other games could potentially use other formats, so they could supply their own version of an argument parser. |
I’ve implemented the first pass of arguments parsing. |
Wow that's one complex approach. I have a simpler one, store arguments by their respective types and parse them in one pass. Imagine something like this: void callback(ArgParser p) {
p = p.args(int.class, float.class, String.class).opt(int.class, "example", "e"); // And so on
int arg1 = p.get(0);
// ...
int example = p.getOrElse("example", 5);
} ArgsParser would be immutable so that you can have multiple sets of arguments for a command. I haven't quite thought this out yet completely but it's roughly inspired by python's implementation of gnu style options. It spares you the need for creating countless of wrapper types. |
Has my thumbs up |
@Victorious3 can you do a proper github review next time? |
Fancy new feature I won't try to explore with my phone, sorry :P |
@Victorious3 it works fine on the phone, just as you expect... |
@RX14 I'm not expecting much considering that I cant even edit my comments without requesting the desktop version. |
@Victorious3 well it does work so ok |
96cc395
to
b100ef4
Compare
dcae3b5
to
bef0988
Compare
dd94c58
to
a5109ac
Compare
EnumSelector<Errors> errored = EnumSelector.of(Errors.class).blockAll(); | ||
|
||
for (String stringArg : args) { | ||
if (optional || continuos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuos
is a typo
public void testEquals() { | ||
assertThat(args0.equals(args0)).isTrue(); | ||
assertThat(args2.equals(args3)).isFalse(); | ||
assertThat(args1.equals(new ArgsParser("Arg1").args(String.class).parse())).isTrue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEqualTo
assertion if possible?
|
||
@Test | ||
public void testHashCode() { | ||
System.out.println("args0: " + args0.hashCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No printlns in test code! The results must be verifiable in code. This is useful for getting started but should be codified later.
@Victorious3 do you want to review this? |
cf06423
to
d9d9bd9
Compare
306fdc5
to
00bd056
Compare
00bd056
to
4e99586
Compare
This is my draft of NOVA-Commands.
I’ve implemented this according to the discussion at NOVA-Team/NOVA-Monorepo#224.
It might be best to wait until NOVA-Team/NOVA-Monorepo#244 is resolved, so that I can optionally add JSON to Data deserialization support.
To do:
ArgsParser
class to be correct according the POSIX Utility Arguments Syntax.Closes NOVA-Team/NOVA-Monorepo#224
Note that as the creator of this repository, I can merge this PR myself.