Removal of event bus complete

This commit is contained in:
Zontreck 2024-02-14 04:26:30 -07:00
parent 1bff37ef0f
commit 261cc7673f
3 changed files with 1 additions and 90 deletions

View file

@ -1,26 +0,0 @@
package dev.zontreck.ariaslib.events;
import dev.zontreck.eventsbus.Event;
import dev.zontreck.eventsbus.annotations.Cancellable;
import java.util.ArrayList;
import java.util.List;
@Cancellable
public class CommandEvent extends Event {
public String command;
public List<String> arguments = new ArrayList<>();
public CommandEvent(String commandString) {
String[] cmds = commandString.split(" ");
if (cmds.length > 0) {
command = cmds[0];
if (cmds.length == 1) return;
for (int i = 1; i < cmds.length; i++) {
arguments.add(cmds[i]);
}
} else throw new IllegalArgumentException("The command cannot be empty!");
}
}

View file

@ -1,11 +1,8 @@
package dev.zontreck.ariaslib.terminal; package dev.zontreck.ariaslib.terminal;
import dev.zontreck.ariaslib.events.CommandEvent;
import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.eventsbus.Bus;
import java.io.Console; import java.io.Console;
@Deprecated
public class ConsolePrompt extends Task { public class ConsolePrompt extends Task {
public static final Console console = System.console(); public static final Console console = System.console();
@ -17,13 +14,6 @@ public class ConsolePrompt extends Task {
@Override @Override
public void run() { public void run() {
// Print a prompt // Print a prompt
console.printf("\n" + Terminal.PREFIX + " > ");
String commandInput = console.readLine();
CommandEvent event = new CommandEvent(commandInput);
if (!Bus.Post(event)) {
DelayedExecutorService.getInstance().schedule(new ConsolePrompt(), 2);
}
} }

View file

@ -1,53 +0,0 @@
package dev.zontreck.ariaslib.args;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.jupiter.api.Assertions.*;
public class ArgumentsParserTest {
@ParameterizedTest
@ValueSource(strings = {"--test", "--arg", "--testing2"})
void testGetNamePart(String entry) {
String arg = ArgumentsParser.getNamePart(entry);
assertFalse(arg.startsWith("--"));
assertFalse(arg.isEmpty());
}
@ParameterizedTest
@CsvSource(value = {"test", "test2", "281", "true"})
void testGetValuePart(String entry) {
assertFalse(entry.isEmpty());
}
@ParameterizedTest
@ValueSource(strings = {"test", "1", "922337203685477580", ""})
void testGetArgumentType(String input)
{
ArgumentType test = ArgumentsParser.getArgumentType(input);
System.out.println("Testing: " + input + "; Type: " + test);
if(input.startsWith("t"))
{
assertTrue(test == ArgumentType.STRING);
}else if(input.startsWith("1"))
{
assertTrue(test == ArgumentType.INTEGER);
} else if(input.startsWith("9"))
{
assertTrue(test == ArgumentType.LONG);
}else assertTrue(test == ArgumentType.BOOLEAN);
}
@ParameterizedTest
@CsvSource(value = {"--test=1", "--enable", "--set=84375488888444", "--file=test.dat"})
void testParseArgument(String arg)
{
Argument args = ArgumentsParser.parseArgument(arg);
assertFalse(args.name.isEmpty());
assertTrue(args.hasValue);
}
}