Removed : int (for example) in syntax.

We can have better ways to show this, without making usage text so long.
This commit is contained in:
Nathan Adams 2017-11-06 16:14:29 +01:00
parent 59a27953be
commit c746232ffc
10 changed files with 3 additions and 63 deletions

View file

@ -16,7 +16,4 @@ public interface ArgumentType<T> {
return null;
}
default String getUsageText() {
return null;
}
}

View file

@ -21,9 +21,4 @@ public class BoolArgumentType implements ArgumentType<Boolean> {
public <S> Boolean parse(final StringReader reader, final CommandContextBuilder<S> contextBuilder) throws CommandSyntaxException {
return reader.readBoolean();
}
@Override
public String getUsageText() {
return "bool";
}
}

View file

@ -95,9 +95,4 @@ public class FloatArgumentType implements ArgumentType<Float> {
public String getUsageSuffix() {
return suffix.length() == 0 ? null : suffix;
}
@Override
public String getUsageText() {
return "float";
}
}

View file

@ -95,9 +95,4 @@ public class IntegerArgumentType implements ArgumentType<Integer> {
public String getUsageSuffix() {
return suffix.length() == 0 ? null : suffix;
}
@Override
public String getUsageText() {
return "int";
}
}

View file

@ -69,11 +69,6 @@ public class StringArgumentType implements ArgumentType<String> {
return result.toString();
}
@Override
public String getUsageText() {
return "string";
}
public enum StringType {
SINGLE_WORD,
QUOTABLE_PHRASE,

View file

@ -43,11 +43,7 @@ public class ArgumentCommandNode<S, T> extends CommandNode<S> {
@Override
public String getUsageText() {
String usage = name;
if (type.getUsageText() != null) {
usage += ": " + type.getUsageText();
}
usage = USAGE_ARGUMENT_OPEN + usage + USAGE_ARGUMENT_CLOSE;
String usage = USAGE_ARGUMENT_OPEN + name + USAGE_ARGUMENT_CLOSE;
if (type.getUsageSuffix() != null) {
usage += type.getUsageSuffix();
}

View file

@ -34,9 +34,4 @@ public class BoolArgumentTypeTest {
assertThat(type.parse(reader, context), is(true));
verify(reader).readBoolean();
}
@Test
public void usageText() throws Exception {
assertThat(type.getUsageText(), equalTo("bool"));
}
}

View file

@ -137,14 +137,4 @@ public class FloatArgumentTypeTest {
public void testUsageSuffix_suffix() throws Exception {
assertThat(floatArg(0, 100, "L").getUsageSuffix(), equalTo("L"));
}
@Test
public void testUsageText() throws Exception {
assertThat(floatArg().getUsageText(), equalTo("float"));
}
@Test
public void testUsageText_suffix() throws Exception {
assertThat(floatArg(0, 100, "L").getUsageText(), equalTo("float"));
}
}

View file

@ -137,14 +137,4 @@ public class IntegerArgumentTypeTest {
public void testUsageSuffix_suffix() throws Exception {
assertThat(integer(0, 100, "L").getUsageSuffix(), equalTo("L"));
}
@Test
public void testUsageText() throws Exception {
assertThat(integer().getUsageText(), equalTo("int"));
}
@Test
public void testUsageText_suffix() throws Exception {
assertThat(integer(0, 100, "L").getUsageText(), equalTo("int"));
}
}

View file

@ -48,21 +48,13 @@ public class ArgumentCommandNodeTest extends AbstractCommandNodeTest {
@Test
public void testUsage() throws Exception {
assertThat(node.getUsageText(), is("<foo: int>"));
assertThat(node.getUsageText(), is("<foo>"));
}
@Test
public void testUsage_suffix() throws Exception {
node = argument("foo", integer(0, 100, "L")).build();
assertThat(node.getUsageText(), is("<foo: int>L"));
}
@Test
public void testUsage_empty() throws Exception {
@SuppressWarnings("unchecked") final ArgumentType<String> type = mock(ArgumentType.class);
when(type.getUsageText()).thenReturn(null);
final ArgumentCommandNode<Object, String> node = argument("foo", type).build();
assertThat(node.getUsageText(), is("<foo>"));
assertThat(node.getUsageText(), is("<foo>L"));
}
@Test