Add flag support to the annotation system.

This commit is contained in:
Alexander Söderberg 2020-10-02 20:52:35 +02:00
parent 782f3023fc
commit c67619e5da
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
9 changed files with 214 additions and 2 deletions

View file

@ -58,6 +58,8 @@ class AnnotationParserTest {
manager.executeCommand(new TestCommandSender(), "proxycommand 10").join();
Assertions.assertThrows(CompletionException.class, () ->
manager.executeCommand(new TestCommandSender(), "test 101").join());
manager.executeCommand(new TestCommandSender(), "flagcommand -p").join();
manager.executeCommand(new TestCommandSender(), "flagcommand --print --word peanut").join();
}
@ProxiedBy("proxycommand")
@ -69,4 +71,13 @@ class AnnotationParserTest {
System.out.printf("Received int: %d and string '%s'\n", argument, string);
}
@CommandMethod("flagcommand")
public void testFlags(final TestCommandSender sender,
@Flag(value = "print", aliases = "p") boolean print,
@Flag(value = "word", aliases = "w") String word) {
if (print) {
System.out.println(word);
}
}
}