- * Instantiate this singleton once in your entrypoint method. the Espresso Argument Parser is effectively the main class
+ *
Argument Parser (EAP)
+ * Instantiate this singleton once in your entrypoint method. The Argument Parser is effectively the main class
* of your command line application.
*/
-public class EspressoArgumentParser {
- private static EspressoArgumentParser instance;
+public class ArgumentParser {
+ private static ArgumentParser instance;
@Getter
private final String applicationName;
@@ -31,9 +31,9 @@ public class EspressoArgumentParser {
* @param applicationName The name of your EAP application
* @param applicationDescription A short description of your EAP application
*/
- public EspressoArgumentParser(String applicationName, String applicationDescription) {
+ public ArgumentParser(String applicationName, String applicationDescription) {
if (instance != null) {
- throw new RuntimeException("An EspressoArgumentParser has already been instantiated (application name=\"%s\")".formatted(applicationName));
+ throw new RuntimeException("An ArgumentParser has already been instantiated (application name=\"%s\")".formatted(applicationName));
}
this.applicationName = applicationName;
this.applicationDescription = applicationDescription;
@@ -51,11 +51,11 @@ public EspressoArgumentParser(String applicationName, String applicationDescript
/**
* Get the singleton instance
*
- * @return Singleton of EspressoArgumentParser
+ * @return Singleton of ArgumentParser
*/
- private static EspressoArgumentParser getInstance() {
+ private static ArgumentParser getInstance() {
if (instance == null) {
- throw new RuntimeException("An EspressoArgumentParser was never instantiated, therefore there is no instance to retrieve");
+ throw new RuntimeException("An ArgumentParser was never instantiated, therefore there is no instance to retrieve");
}
return instance;
}
@@ -65,10 +65,10 @@ private static EspressoArgumentParser getInstance() {
*
* @param commandContainer CommandContainer instance
*/
- public void addCommandContainer(CommandContainer commandContainer) throws EapDuplicateCommandContainerException {
+ public void addCommandContainer(CommandContainer commandContainer) throws DuplicateCommandContainerException {
for (CommandContainer iterCommandContainer : commandContainerList) {
if (iterCommandContainer.getName().equals(commandContainer.getName())) {
- throw new EapDuplicateCommandContainerException();
+ throw new DuplicateCommandContainerException();
}
}
commandContainerList.add(commandContainer);
@@ -79,10 +79,10 @@ public void addCommandContainer(CommandContainer commandContainer) throws EapDup
*
* @param command Command instance
*/
- public void addCommand(Command command) throws EapDuplicateCommandException {
+ public void addCommand(Command command) throws DuplicateCommandException {
for (Command iterCommand : commandList) {
if (iterCommand.getName().equals(command.getName())) {
- throw new EapDuplicateCommandException();
+ throw new DuplicateCommandException();
}
}
commandList.add(command);
@@ -94,10 +94,10 @@ public void addCommand(Command command) throws EapDuplicateCommandException {
*
* @param commandContainer Command Container to search under
*/
- private void parseInCommandContainer(CommandContainer commandContainer, String[] remainingArgs) throws EapCommandNotFoundException, EapMalformedCommandModifierException, EapCommandModifierNotFoundException, EapCommandNotSpecifiedException {
+ private void parseInCommandContainer(CommandContainer commandContainer, String[] remainingArgs) throws CommandNotFoundException, MalformedCommandModifierException, CommandModifierNotFoundException, CommandNotSpecifiedException {
// check if the user specified a command after their subcommand
if (remainingArgs.length == 0) {
- throw new EapCommandNotSpecifiedException(commandContainer.getName());
+ throw new CommandNotSpecifiedException(commandContainer.getName());
}
// separate out our next-in-line command
@@ -118,7 +118,7 @@ private void parseInCommandContainer(CommandContainer commandContainer, String[]
return;
}
}
- throw new EapCommandNotFoundException(commandName);
+ throw new CommandNotFoundException(commandName);
}
/**
@@ -133,7 +133,7 @@ public void addExceptionHandler(ExceptionHandler exceptionHandler) {
*
* @param arguments Arg array from main method
*/
- public void parse(String[] arguments) throws EapMissingSubcommandException, EapCommandNotFoundException, EapMalformedCommandModifierException, EapSubcommandNotFoundException, EapCommandModifierNotFoundException, EapCommandNotSpecifiedException {
+ public void parse(String[] arguments) throws EapMissingSubcommandException, CommandNotFoundException, MalformedCommandModifierException, EapSubcommandNotFoundException, CommandModifierNotFoundException, CommandNotSpecifiedException {
try {
// if no arguments were provided
if (arguments.length == 0) {
diff --git a/src/main/java/xyz/hlafaille/eap/Command.java b/src/main/java/io/kerosenelabs/arg/Command.java
similarity index 77%
rename from src/main/java/xyz/hlafaille/eap/Command.java
rename to src/main/java/io/kerosenelabs/arg/Command.java
index 82397b4..d8a72bb 100644
--- a/src/main/java/xyz/hlafaille/eap/Command.java
+++ b/src/main/java/io/kerosenelabs/arg/Command.java
@@ -1,14 +1,14 @@
-package xyz.hlafaille.eap;
+package io.kerosenelabs.arg;
+import io.kerosenelabs.arg.exception.CommandModifierNotFoundException;
+import io.kerosenelabs.arg.exception.MalformedCommandModifierException;
import lombok.Getter;
-import xyz.hlafaille.eap.exception.EapCommandModifierNotFoundException;
-import xyz.hlafaille.eap.exception.EapMalformedCommandModifierException;
import java.util.ArrayList;
import java.util.List;
/**
- *
Espresso Argument Parser Command
+ *
Argument Parser Command
*/
public abstract class Command {
@Getter
@@ -36,17 +36,17 @@ public void addCommandModifier(CommandModifier commandModifier) {
}
/**
- * Automatically called by the EspressoArgumentParser, this method primarily does parsing and type checking on
+ * Automatically called by the ArgumentParser, this method primarily does parsing and type checking on
* any potential command modifiers passed.
*
* @param remainingArgs Array of remaining args
*/
- public void preExecute(String[] remainingArgs) throws EapMalformedCommandModifierException, EapCommandModifierNotFoundException {
+ public void preExecute(String[] remainingArgs) throws MalformedCommandModifierException, CommandModifierNotFoundException {
List commandModifiers = new ArrayList<>();
for (String arg : remainingArgs) {
// if this command modifier doesn't include "--"
if (!arg.contains("--")) {
- throw new EapMalformedCommandModifierException(arg);
+ throw new MalformedCommandModifierException(arg);
}
// strip out the "--"
@@ -63,7 +63,7 @@ public void preExecute(String[] remainingArgs) throws EapMalformedCommandModifie
// if the requested command modifier could not be found
if (!commandModifierMatchFound) {
- throw new EapCommandModifierNotFoundException(arg);
+ throw new CommandModifierNotFoundException(arg);
}
}
execute(commandModifiers);
diff --git a/src/main/java/xyz/hlafaille/eap/CommandContainer.java b/src/main/java/io/kerosenelabs/arg/CommandContainer.java
similarity index 97%
rename from src/main/java/xyz/hlafaille/eap/CommandContainer.java
rename to src/main/java/io/kerosenelabs/arg/CommandContainer.java
index a857d0f..12b227b 100644
--- a/src/main/java/xyz/hlafaille/eap/CommandContainer.java
+++ b/src/main/java/io/kerosenelabs/arg/CommandContainer.java
@@ -1,4 +1,4 @@
-package xyz.hlafaille.eap;
+package io.kerosenelabs.arg;
import lombok.Getter;
diff --git a/src/main/java/xyz/hlafaille/eap/CommandModifier.java b/src/main/java/io/kerosenelabs/arg/CommandModifier.java
similarity index 85%
rename from src/main/java/xyz/hlafaille/eap/CommandModifier.java
rename to src/main/java/io/kerosenelabs/arg/CommandModifier.java
index 740e2e2..74d2f54 100644
--- a/src/main/java/xyz/hlafaille/eap/CommandModifier.java
+++ b/src/main/java/io/kerosenelabs/arg/CommandModifier.java
@@ -1,10 +1,9 @@
-package xyz.hlafaille.eap;
+package io.kerosenelabs.arg;
-import lombok.AllArgsConstructor;
import lombok.Getter;
/**
- *
Espresso Argument Parser Command Modifier
+ *
Argument Parser Command Modifier
* A command modifier can modify the input/output of a command, but shouldn't be considered an "input". For example,
* with the following Docker command:
*
diff --git a/src/main/java/xyz/hlafaille/eap/ExceptionHandler.java b/src/main/java/io/kerosenelabs/arg/ExceptionHandler.java
similarity index 78%
rename from src/main/java/xyz/hlafaille/eap/ExceptionHandler.java
rename to src/main/java/io/kerosenelabs/arg/ExceptionHandler.java
index 23fb6ed..0ea2cd5 100644
--- a/src/main/java/xyz/hlafaille/eap/ExceptionHandler.java
+++ b/src/main/java/io/kerosenelabs/arg/ExceptionHandler.java
@@ -1,9 +1,7 @@
-package xyz.hlafaille.eap;
-
-import lombok.Getter;
+package io.kerosenelabs.arg;
/**
- * Tells the Espresso Argument Parser how to deal with a specific exception
+ * Tells the Argument Parser how to deal with a specific exception
*/
public abstract class ExceptionHandler {
private final Class exceptionClass;
diff --git a/src/main/java/io/kerosenelabs/arg/Main.java b/src/main/java/io/kerosenelabs/arg/Main.java
new file mode 100644
index 0000000..a47a5a9
--- /dev/null
+++ b/src/main/java/io/kerosenelabs/arg/Main.java
@@ -0,0 +1,23 @@
+package io.kerosenelabs.arg;
+
+import io.kerosenelabs.arg.exception.*;
+
+import java.util.List;
+
+public class Main {
+ public static void main(String[] args) throws CommandNotFoundException, EapMissingSubcommandException, DuplicateCommandContainerException, MalformedCommandModifierException, EapSubcommandNotFoundException, CommandModifierNotFoundException, CommandNotSpecifiedException, DuplicateCommandException {
+ ArgumentParser argumentParser = new ArgumentParser("EAP Application", "Test");
+
+ // build our command
+ Command command = new Command("test", "test") {
+ @Override
+ public void execute(List commandModifiers) {
+ System.out.println(commandModifiers);
+ }
+ };
+ argumentParser.addCommand(command);
+
+ // entrypoint
+ argumentParser.parse(args);
+ }
+}
diff --git a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapCommandModifierNotFoundExceptionHandler.java b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapCommandModifierNotFoundExceptionHandler.java
similarity index 53%
rename from src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapCommandModifierNotFoundExceptionHandler.java
rename to src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapCommandModifierNotFoundExceptionHandler.java
index 0a2552c..50cbeb4 100644
--- a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapCommandModifierNotFoundExceptionHandler.java
+++ b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapCommandModifierNotFoundExceptionHandler.java
@@ -1,15 +1,15 @@
-package xyz.hlafaille.eap.buitlin.exceptionhandler;
+package io.kerosenelabs.arg.buitlin.exceptionhandler;
-import xyz.hlafaille.eap.ExceptionHandler;
-import xyz.hlafaille.eap.exception.EapCommandNotSpecifiedException;
-import xyz.hlafaille.eap.util.ColorLogger;
+import io.kerosenelabs.arg.ExceptionHandler;
+import io.kerosenelabs.arg.exception.CommandNotSpecifiedException;
+import io.kerosenelabs.arg.util.ColorLogger;
/**
* Built in exception handler for: xyz.hlafaille.eap.exception.EapCommandNotSpecifiedException
*/
-public class EapCommandModifierNotFoundExceptionHandler extends ExceptionHandler {
+public class EapCommandModifierNotFoundExceptionHandler extends ExceptionHandler {
public EapCommandModifierNotFoundExceptionHandler() {
- super(EapCommandNotSpecifiedException.class);
+ super(CommandNotSpecifiedException.class);
}
@Override
diff --git a/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapCommandNotFoundExceptionHandler.java b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapCommandNotFoundExceptionHandler.java
new file mode 100644
index 0000000..7d09c93
--- /dev/null
+++ b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapCommandNotFoundExceptionHandler.java
@@ -0,0 +1,19 @@
+package io.kerosenelabs.arg.buitlin.exceptionhandler;
+
+import io.kerosenelabs.arg.ExceptionHandler;
+import io.kerosenelabs.arg.exception.CommandNotFoundException;
+import io.kerosenelabs.arg.util.ColorLogger;
+
+/**
+ * Built in exception handler for: xyz.hlafaille.eap.exception.EapCommandNotFoundExceptionHandler
+ */
+public class EapCommandNotFoundExceptionHandler extends ExceptionHandler {
+ public EapCommandNotFoundExceptionHandler() {
+ super(CommandNotFoundException.class);
+ }
+
+ @Override
+ public void execute(Exception exception) {
+ ColorLogger.severe(exception.getMessage());
+ }
+}
diff --git a/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapCommandNotSpecifiedExceptionHandler.java b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapCommandNotSpecifiedExceptionHandler.java
new file mode 100644
index 0000000..4fddcb0
--- /dev/null
+++ b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapCommandNotSpecifiedExceptionHandler.java
@@ -0,0 +1,19 @@
+package io.kerosenelabs.arg.buitlin.exceptionhandler;
+
+import io.kerosenelabs.arg.ExceptionHandler;
+import io.kerosenelabs.arg.exception.CommandNotSpecifiedException;
+import io.kerosenelabs.arg.util.ColorLogger;
+
+/**
+ * Built in exception handler for: xyz.hlafaille.eap.exception.EapCommandNotSpecifiedException
+ */
+public class EapCommandNotSpecifiedExceptionHandler extends ExceptionHandler {
+ public EapCommandNotSpecifiedExceptionHandler() {
+ super(CommandNotSpecifiedException.class);
+ }
+
+ @Override
+ public void execute(Exception exception) {
+ ColorLogger.severe(exception.getMessage());
+ }
+}
diff --git a/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapDuplicateCommandContainerExceptionHandler.java b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapDuplicateCommandContainerExceptionHandler.java
new file mode 100644
index 0000000..e49d029
--- /dev/null
+++ b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapDuplicateCommandContainerExceptionHandler.java
@@ -0,0 +1,19 @@
+package io.kerosenelabs.arg.buitlin.exceptionhandler;
+
+import io.kerosenelabs.arg.ExceptionHandler;
+import io.kerosenelabs.arg.exception.DuplicateCommandContainerException;
+import io.kerosenelabs.arg.util.ColorLogger;
+
+/**
+ * Built in exception handler for: xyz.hlafaille.eap.exception.EapDuplicateCommandContainerException
+ */
+public class EapDuplicateCommandContainerExceptionHandler extends ExceptionHandler {
+ public EapDuplicateCommandContainerExceptionHandler() {
+ super(DuplicateCommandContainerException.class);
+ }
+
+ @Override
+ public void execute(Exception exception) {
+ ColorLogger.severe(exception.getMessage());
+ }
+}
diff --git a/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapDuplicateCommandExceptionHandler.java b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapDuplicateCommandExceptionHandler.java
new file mode 100644
index 0000000..3d86485
--- /dev/null
+++ b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapDuplicateCommandExceptionHandler.java
@@ -0,0 +1,19 @@
+package io.kerosenelabs.arg.buitlin.exceptionhandler;
+
+import io.kerosenelabs.arg.ExceptionHandler;
+import io.kerosenelabs.arg.exception.DuplicateCommandException;
+import io.kerosenelabs.arg.util.ColorLogger;
+
+/**
+ * Built in exception handler for: xyz.hlafaille.eap.exception.EapDuplicateCommandException
+ */
+public class EapDuplicateCommandExceptionHandler extends ExceptionHandler {
+ public EapDuplicateCommandExceptionHandler() {
+ super(DuplicateCommandException.class);
+ }
+
+ @Override
+ public void execute(Exception exception) {
+ ColorLogger.severe(exception.getMessage());
+ }
+}
diff --git a/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapMalformedCommandModifierExceptionHandler.java b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapMalformedCommandModifierExceptionHandler.java
new file mode 100644
index 0000000..e671b59
--- /dev/null
+++ b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapMalformedCommandModifierExceptionHandler.java
@@ -0,0 +1,19 @@
+package io.kerosenelabs.arg.buitlin.exceptionhandler;
+
+import io.kerosenelabs.arg.ExceptionHandler;
+import io.kerosenelabs.arg.exception.MalformedCommandModifierException;
+import io.kerosenelabs.arg.util.ColorLogger;
+
+/**
+ * Built in exception handler for: xyz.hlafaille.eap.exception.EapMalformedCommandModifierException
+ */
+public class EapMalformedCommandModifierExceptionHandler extends ExceptionHandler {
+ public EapMalformedCommandModifierExceptionHandler() {
+ super(MalformedCommandModifierException.class);
+ }
+
+ @Override
+ public void execute(Exception exception) {
+ ColorLogger.severe(exception.getMessage());
+ }
+}
diff --git a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapMissingSubcommandExceptionHandler.java b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapMissingSubcommandExceptionHandler.java
similarity index 61%
rename from src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapMissingSubcommandExceptionHandler.java
rename to src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapMissingSubcommandExceptionHandler.java
index ee3ef44..5e2daed 100644
--- a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapMissingSubcommandExceptionHandler.java
+++ b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapMissingSubcommandExceptionHandler.java
@@ -1,9 +1,8 @@
-package xyz.hlafaille.eap.buitlin.exceptionhandler;
+package io.kerosenelabs.arg.buitlin.exceptionhandler;
-import xyz.hlafaille.eap.ExceptionHandler;
-import xyz.hlafaille.eap.exception.EapMalformedCommandModifierException;
-import xyz.hlafaille.eap.exception.EapMissingSubcommandException;
-import xyz.hlafaille.eap.util.ColorLogger;
+import io.kerosenelabs.arg.ExceptionHandler;
+import io.kerosenelabs.arg.exception.EapMissingSubcommandException;
+import io.kerosenelabs.arg.util.ColorLogger;
/**
* Built in exception handler for: xyz.hlafaille.eap.exception.EapMissingSubcommandException
diff --git a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapSubcommandNotFoundExceptionHandler.java b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapSubcommandNotFoundExceptionHandler.java
similarity index 62%
rename from src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapSubcommandNotFoundExceptionHandler.java
rename to src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapSubcommandNotFoundExceptionHandler.java
index 91a0572..2d7c048 100644
--- a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapSubcommandNotFoundExceptionHandler.java
+++ b/src/main/java/io/kerosenelabs/arg/buitlin/exceptionhandler/EapSubcommandNotFoundExceptionHandler.java
@@ -1,9 +1,8 @@
-package xyz.hlafaille.eap.buitlin.exceptionhandler;
+package io.kerosenelabs.arg.buitlin.exceptionhandler;
-import xyz.hlafaille.eap.ExceptionHandler;
-import xyz.hlafaille.eap.exception.EapMissingSubcommandException;
-import xyz.hlafaille.eap.exception.EapSubcommandNotFoundException;
-import xyz.hlafaille.eap.util.ColorLogger;
+import io.kerosenelabs.arg.ExceptionHandler;
+import io.kerosenelabs.arg.exception.EapSubcommandNotFoundException;
+import io.kerosenelabs.arg.util.ColorLogger;
/**
* Built in exception handler for: xyz.hlafaille.eap.exception.EapSubcommandNotFoundException
diff --git a/src/main/java/io/kerosenelabs/arg/exception/CommandModifierNotFoundException.java b/src/main/java/io/kerosenelabs/arg/exception/CommandModifierNotFoundException.java
new file mode 100644
index 0000000..04d39b4
--- /dev/null
+++ b/src/main/java/io/kerosenelabs/arg/exception/CommandModifierNotFoundException.java
@@ -0,0 +1,7 @@
+package io.kerosenelabs.arg.exception;
+
+public class CommandModifierNotFoundException extends Exception{
+ public CommandModifierNotFoundException(String userInput) {
+ super("Command modifier not found: %s".formatted(userInput));
+ }
+}
diff --git a/src/main/java/io/kerosenelabs/arg/exception/CommandNotFoundException.java b/src/main/java/io/kerosenelabs/arg/exception/CommandNotFoundException.java
new file mode 100644
index 0000000..63dc9fc
--- /dev/null
+++ b/src/main/java/io/kerosenelabs/arg/exception/CommandNotFoundException.java
@@ -0,0 +1,7 @@
+package io.kerosenelabs.arg.exception;
+
+public class CommandNotFoundException extends Exception{
+ public CommandNotFoundException(String command) {
+ super("No commands or subcommands could be found with the name '%s'".formatted(command));
+ }
+}
diff --git a/src/main/java/xyz/hlafaille/eap/exception/EapCommandNotSpecifiedException.java b/src/main/java/io/kerosenelabs/arg/exception/CommandNotSpecifiedException.java
similarity index 63%
rename from src/main/java/xyz/hlafaille/eap/exception/EapCommandNotSpecifiedException.java
rename to src/main/java/io/kerosenelabs/arg/exception/CommandNotSpecifiedException.java
index cbc2548..7cad858 100644
--- a/src/main/java/xyz/hlafaille/eap/exception/EapCommandNotSpecifiedException.java
+++ b/src/main/java/io/kerosenelabs/arg/exception/CommandNotSpecifiedException.java
@@ -1,11 +1,11 @@
-package xyz.hlafaille.eap.exception;
+package io.kerosenelabs.arg.exception;
/**
* Represents a scenario in which a user types the name of a command container, but not a command under that.
* For example, calling `espresso project` will throw this exception
*/
-public class EapCommandNotSpecifiedException extends Exception {
- public EapCommandNotSpecifiedException(String userInput) {
+public class CommandNotSpecifiedException extends Exception {
+ public CommandNotSpecifiedException(String userInput) {
super("A command must be specified when calling '%s'".formatted(userInput));
}
}
diff --git a/src/main/java/io/kerosenelabs/arg/exception/DuplicateCommandContainerException.java b/src/main/java/io/kerosenelabs/arg/exception/DuplicateCommandContainerException.java
new file mode 100644
index 0000000..773299f
--- /dev/null
+++ b/src/main/java/io/kerosenelabs/arg/exception/DuplicateCommandContainerException.java
@@ -0,0 +1,7 @@
+package io.kerosenelabs.arg.exception;
+
+public class DuplicateCommandContainerException extends Exception{
+ public DuplicateCommandContainerException() {
+ super("Duplicates under command containers are not allowed");
+ }
+}
diff --git a/src/main/java/io/kerosenelabs/arg/exception/DuplicateCommandException.java b/src/main/java/io/kerosenelabs/arg/exception/DuplicateCommandException.java
new file mode 100644
index 0000000..5c91a7d
--- /dev/null
+++ b/src/main/java/io/kerosenelabs/arg/exception/DuplicateCommandException.java
@@ -0,0 +1,7 @@
+package io.kerosenelabs.arg.exception;
+
+public class DuplicateCommandException extends Exception{
+ public DuplicateCommandException() {
+ super("Duplicate commands are not allowed");
+ }
+}
diff --git a/src/main/java/xyz/hlafaille/eap/exception/EapMissingSubcommandException.java b/src/main/java/io/kerosenelabs/arg/exception/EapMissingSubcommandException.java
similarity index 80%
rename from src/main/java/xyz/hlafaille/eap/exception/EapMissingSubcommandException.java
rename to src/main/java/io/kerosenelabs/arg/exception/EapMissingSubcommandException.java
index d91bd07..5c3aabe 100644
--- a/src/main/java/xyz/hlafaille/eap/exception/EapMissingSubcommandException.java
+++ b/src/main/java/io/kerosenelabs/arg/exception/EapMissingSubcommandException.java
@@ -1,4 +1,4 @@
-package xyz.hlafaille.eap.exception;
+package io.kerosenelabs.arg.exception;
public class EapMissingSubcommandException extends Exception{
public EapMissingSubcommandException() {
diff --git a/src/main/java/xyz/hlafaille/eap/exception/EapSubcommandNotFoundException.java b/src/main/java/io/kerosenelabs/arg/exception/EapSubcommandNotFoundException.java
similarity index 84%
rename from src/main/java/xyz/hlafaille/eap/exception/EapSubcommandNotFoundException.java
rename to src/main/java/io/kerosenelabs/arg/exception/EapSubcommandNotFoundException.java
index 841f5bb..abd4d59 100644
--- a/src/main/java/xyz/hlafaille/eap/exception/EapSubcommandNotFoundException.java
+++ b/src/main/java/io/kerosenelabs/arg/exception/EapSubcommandNotFoundException.java
@@ -1,4 +1,4 @@
-package xyz.hlafaille.eap.exception;
+package io.kerosenelabs.arg.exception;
public class EapSubcommandNotFoundException extends Exception{
public EapSubcommandNotFoundException(String command) {
diff --git a/src/main/java/xyz/hlafaille/eap/exception/EapMalformedCommandModifierException.java b/src/main/java/io/kerosenelabs/arg/exception/MalformedCommandModifierException.java
similarity index 55%
rename from src/main/java/xyz/hlafaille/eap/exception/EapMalformedCommandModifierException.java
rename to src/main/java/io/kerosenelabs/arg/exception/MalformedCommandModifierException.java
index 6f4f5d0..000017e 100644
--- a/src/main/java/xyz/hlafaille/eap/exception/EapMalformedCommandModifierException.java
+++ b/src/main/java/io/kerosenelabs/arg/exception/MalformedCommandModifierException.java
@@ -1,10 +1,10 @@
-package xyz.hlafaille.eap.exception;
+package io.kerosenelabs.arg.exception;
/**
* Represents a scenario in which the user provides a command modifier that was not expected or malformed
*/
-public class EapMalformedCommandModifierException extends Exception {
- public EapMalformedCommandModifierException(String userInput) {
+public class MalformedCommandModifierException extends Exception {
+ public MalformedCommandModifierException(String userInput) {
super("Malformed command modifier, user provided input was: %s".formatted(userInput));
}
}
diff --git a/src/main/java/xyz/hlafaille/eap/util/ColorLogger.java b/src/main/java/io/kerosenelabs/arg/util/ColorLogger.java
similarity index 92%
rename from src/main/java/xyz/hlafaille/eap/util/ColorLogger.java
rename to src/main/java/io/kerosenelabs/arg/util/ColorLogger.java
index 36537bd..b468e08 100644
--- a/src/main/java/xyz/hlafaille/eap/util/ColorLogger.java
+++ b/src/main/java/io/kerosenelabs/arg/util/ColorLogger.java
@@ -1,7 +1,4 @@
-package xyz.hlafaille.eap.util;
-
-import lombok.Getter;
-
+package io.kerosenelabs.arg.util;
public class ColorLogger {
public static final String ANSI_RESET = "\u001B[0m";
diff --git a/src/main/java/xyz/hlafaille/eap/Main.java b/src/main/java/xyz/hlafaille/eap/Main.java
deleted file mode 100644
index 39eab3b..0000000
--- a/src/main/java/xyz/hlafaille/eap/Main.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package xyz.hlafaille.eap;
-
-import xyz.hlafaille.eap.buitlin.exceptionhandler.EapCommandModifierNotFoundExceptionHandler;
-import xyz.hlafaille.eap.exception.*;
-
-import java.util.List;
-
-public class Main {
- public static void main(String[] args) throws EapCommandNotFoundException, EapMissingSubcommandException, EapDuplicateCommandContainerException, EapMalformedCommandModifierException, EapSubcommandNotFoundException, EapCommandModifierNotFoundException, EapCommandNotSpecifiedException, EapDuplicateCommandException {
- EspressoArgumentParser espressoArgumentParser = new EspressoArgumentParser("EAP Application", "Test");
-
- // build our command
- Command command = new Command("test", "test") {
- @Override
- public void execute(List commandModifiers) {
- System.out.println(commandModifiers);
- }
- };
- espressoArgumentParser.addCommand(command);
-
- // entrypoint
- espressoArgumentParser.parse(args);
- }
-}
diff --git a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapCommandNotFoundExceptionHandler.java b/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapCommandNotFoundExceptionHandler.java
deleted file mode 100644
index c028524..0000000
--- a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapCommandNotFoundExceptionHandler.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package xyz.hlafaille.eap.buitlin.exceptionhandler;
-
-import xyz.hlafaille.eap.ExceptionHandler;
-import xyz.hlafaille.eap.exception.EapCommandNotFoundException;
-import xyz.hlafaille.eap.exception.EapCommandNotSpecifiedException;
-import xyz.hlafaille.eap.util.ColorLogger;
-
-/**
- * Built in exception handler for: xyz.hlafaille.eap.exception.EapCommandNotFoundExceptionHandler
- */
-public class EapCommandNotFoundExceptionHandler extends ExceptionHandler {
- public EapCommandNotFoundExceptionHandler() {
- super(EapCommandNotFoundException.class);
- }
-
- @Override
- public void execute(Exception exception) {
- ColorLogger.severe(exception.getMessage());
- }
-}
diff --git a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapCommandNotSpecifiedExceptionHandler.java b/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapCommandNotSpecifiedExceptionHandler.java
deleted file mode 100644
index cfd72da..0000000
--- a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapCommandNotSpecifiedExceptionHandler.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package xyz.hlafaille.eap.buitlin.exceptionhandler;
-
-import xyz.hlafaille.eap.ExceptionHandler;
-import xyz.hlafaille.eap.exception.EapCommandNotFoundException;
-import xyz.hlafaille.eap.exception.EapCommandNotSpecifiedException;
-import xyz.hlafaille.eap.util.ColorLogger;
-
-/**
- * Built in exception handler for: xyz.hlafaille.eap.exception.EapCommandNotSpecifiedException
- */
-public class EapCommandNotSpecifiedExceptionHandler extends ExceptionHandler {
- public EapCommandNotSpecifiedExceptionHandler() {
- super(EapCommandNotSpecifiedException.class);
- }
-
- @Override
- public void execute(Exception exception) {
- ColorLogger.severe(exception.getMessage());
- }
-}
diff --git a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapDuplicateCommandContainerExceptionHandler.java b/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapDuplicateCommandContainerExceptionHandler.java
deleted file mode 100644
index 2708248..0000000
--- a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapDuplicateCommandContainerExceptionHandler.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package xyz.hlafaille.eap.buitlin.exceptionhandler;
-
-import xyz.hlafaille.eap.ExceptionHandler;
-import xyz.hlafaille.eap.exception.EapCommandNotSpecifiedException;
-import xyz.hlafaille.eap.exception.EapDuplicateCommandContainerException;
-import xyz.hlafaille.eap.util.ColorLogger;
-
-/**
- * Built in exception handler for: xyz.hlafaille.eap.exception.EapDuplicateCommandContainerException
- */
-public class EapDuplicateCommandContainerExceptionHandler extends ExceptionHandler {
- public EapDuplicateCommandContainerExceptionHandler() {
- super(EapDuplicateCommandContainerException.class);
- }
-
- @Override
- public void execute(Exception exception) {
- ColorLogger.severe(exception.getMessage());
- }
-}
diff --git a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapDuplicateCommandExceptionHandler.java b/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapDuplicateCommandExceptionHandler.java
deleted file mode 100644
index 3b7b40a..0000000
--- a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapDuplicateCommandExceptionHandler.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package xyz.hlafaille.eap.buitlin.exceptionhandler;
-
-import xyz.hlafaille.eap.ExceptionHandler;
-import xyz.hlafaille.eap.exception.EapDuplicateCommandContainerException;
-import xyz.hlafaille.eap.exception.EapDuplicateCommandException;
-import xyz.hlafaille.eap.util.ColorLogger;
-
-/**
- * Built in exception handler for: xyz.hlafaille.eap.exception.EapDuplicateCommandException
- */
-public class EapDuplicateCommandExceptionHandler extends ExceptionHandler {
- public EapDuplicateCommandExceptionHandler() {
- super(EapDuplicateCommandException.class);
- }
-
- @Override
- public void execute(Exception exception) {
- ColorLogger.severe(exception.getMessage());
- }
-}
diff --git a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapMalformedCommandModifierExceptionHandler.java b/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapMalformedCommandModifierExceptionHandler.java
deleted file mode 100644
index 09322c5..0000000
--- a/src/main/java/xyz/hlafaille/eap/buitlin/exceptionhandler/EapMalformedCommandModifierExceptionHandler.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package xyz.hlafaille.eap.buitlin.exceptionhandler;
-
-import xyz.hlafaille.eap.ExceptionHandler;
-import xyz.hlafaille.eap.exception.EapDuplicateCommandContainerException;
-import xyz.hlafaille.eap.exception.EapMalformedCommandModifierException;
-import xyz.hlafaille.eap.util.ColorLogger;
-
-/**
- * Built in exception handler for: xyz.hlafaille.eap.exception.EapMalformedCommandModifierException
- */
-public class EapMalformedCommandModifierExceptionHandler extends ExceptionHandler {
- public EapMalformedCommandModifierExceptionHandler() {
- super(EapMalformedCommandModifierException.class);
- }
-
- @Override
- public void execute(Exception exception) {
- ColorLogger.severe(exception.getMessage());
- }
-}
diff --git a/src/main/java/xyz/hlafaille/eap/exception/EapCommandModifierNotFoundException.java b/src/main/java/xyz/hlafaille/eap/exception/EapCommandModifierNotFoundException.java
deleted file mode 100644
index 3d17ccc..0000000
--- a/src/main/java/xyz/hlafaille/eap/exception/EapCommandModifierNotFoundException.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package xyz.hlafaille.eap.exception;
-
-public class EapCommandModifierNotFoundException extends Exception{
- public EapCommandModifierNotFoundException(String userInput) {
- super("Command modifier not found: %s".formatted(userInput));
- }
-}
diff --git a/src/main/java/xyz/hlafaille/eap/exception/EapCommandNotFoundException.java b/src/main/java/xyz/hlafaille/eap/exception/EapCommandNotFoundException.java
deleted file mode 100644
index a252d64..0000000
--- a/src/main/java/xyz/hlafaille/eap/exception/EapCommandNotFoundException.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package xyz.hlafaille.eap.exception;
-
-public class EapCommandNotFoundException extends Exception{
- public EapCommandNotFoundException(String command) {
- super("No commands or subcommands could be found with the name '%s'".formatted(command));
- }
-}
diff --git a/src/main/java/xyz/hlafaille/eap/exception/EapDuplicateCommandContainerException.java b/src/main/java/xyz/hlafaille/eap/exception/EapDuplicateCommandContainerException.java
deleted file mode 100644
index 2f3a8b1..0000000
--- a/src/main/java/xyz/hlafaille/eap/exception/EapDuplicateCommandContainerException.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package xyz.hlafaille.eap.exception;
-
-public class EapDuplicateCommandContainerException extends Exception{
- public EapDuplicateCommandContainerException() {
- super("Duplicates under command containers are not allowed");
- }
-}
diff --git a/src/main/java/xyz/hlafaille/eap/exception/EapDuplicateCommandException.java b/src/main/java/xyz/hlafaille/eap/exception/EapDuplicateCommandException.java
deleted file mode 100644
index d4d85b4..0000000
--- a/src/main/java/xyz/hlafaille/eap/exception/EapDuplicateCommandException.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package xyz.hlafaille.eap.exception;
-
-public class EapDuplicateCommandException extends Exception{
- public EapDuplicateCommandException() {
- super("Duplicate commands are not allowed");
- }
-}
diff --git a/src/test/java/xyz/hlafaille/eap/TestEspressoArgumentParser.java b/src/test/java/io/kerosenelabs/arg/TestEspressoArgumentParser.java
similarity index 60%
rename from src/test/java/xyz/hlafaille/eap/TestEspressoArgumentParser.java
rename to src/test/java/io/kerosenelabs/arg/TestEspressoArgumentParser.java
index 74e74fa..7244d79 100644
--- a/src/test/java/xyz/hlafaille/eap/TestEspressoArgumentParser.java
+++ b/src/test/java/io/kerosenelabs/arg/TestEspressoArgumentParser.java
@@ -1,4 +1,4 @@
-package xyz.hlafaille.eap;
+package io.kerosenelabs.arg;
public class TestEspressoArgumentParser {
}