Version bump.

This commit is contained in:
Alexander Söderberg 2020-09-22 18:58:43 +02:00
parent a6db68fa66
commit 7501bd4743
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
16 changed files with 47 additions and 41 deletions

View file

@ -35,7 +35,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<artifactId>cloud-core</artifactId>
<dependencies>

View file

@ -265,6 +265,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
boolean started = false;
boolean finished = false;
char start = ' ';
for (int i = 0; i < size; i++) {
String string = inputQueue.peek();
@ -274,13 +275,16 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
if (this.stringMode == StringMode.QUOTED) {
if (!started) {
if (string.startsWith("\"")) {
if (string.startsWith("\"") || string.startsWith("'")) {
start = string.charAt(0);
string = string.substring(1);
started = true;
} else {
return ArgumentParseResult.failure(new StringParseException(string, StringMode.QUOTED));
/* Just read a single string instead */
inputQueue.remove();
return ArgumentParseResult.success(string);
}
} else if (string.endsWith("\"")) {
} else if (string.endsWith(Character.toString(start))) {
sj.add(string.substring(0, string.length() - 1));
inputQueue.remove();
finished = true;

View file

@ -30,8 +30,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class StringArgumentTest {
private static final String[] storage = new String[2];
@ -80,8 +78,12 @@ class StringArgumentTest {
@Test
void testQuotes() {
clear();
manager.executeCommand(new TestCommandSender(), "quoted \"quoted string\" unquoted").join();
Assertions.assertEquals("quoted string", storage[0]);
manager.executeCommand(new TestCommandSender(), "quoted 'quoted \" string' unquoted").join();
Assertions.assertEquals("quoted \" string", storage[0]);
Assertions.assertEquals("unquoted", storage[1]);
clear();
manager.executeCommand(new TestCommandSender(), "quoted quoted unquoted");
Assertions.assertEquals("quoted", storage[0]);
Assertions.assertEquals("unquoted", storage[1]);
}