From 533af43bead526c872e48e8500a51d60bd03d882 Mon Sep 17 00:00:00 2001 From: tueem Date: Mon, 14 Oct 2024 17:11:14 +0200 Subject: [PATCH] rename of the Command data class --- ....java => ExecutableCommandDefinition.java} | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) rename lib/src/main/java/net/tomatentum/marinara/interaction/commands/{CommandDefinition.java => ExecutableCommandDefinition.java} (68%) diff --git a/lib/src/main/java/net/tomatentum/marinara/interaction/commands/CommandDefinition.java b/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableCommandDefinition.java similarity index 68% rename from lib/src/main/java/net/tomatentum/marinara/interaction/commands/CommandDefinition.java rename to lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableCommandDefinition.java index a8c623d..fc224f8 100644 --- a/lib/src/main/java/net/tomatentum/marinara/interaction/commands/CommandDefinition.java +++ b/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableCommandDefinition.java @@ -1,12 +1,22 @@ package net.tomatentum.marinara.interaction.commands; -public record CommandDefinition(String applicationCommand, String applicationCommandDescription, String[] subCommandGroups, String subCommand, String subCommandDescription) { +import org.apache.logging.log4j.core.tools.picocli.CommandLine.Command; + +import net.tomatentum.marinara.interaction.commands.annotation.CommandOption; + +public record ExecutableCommandDefinition( + String applicationCommand, + String applicationCommandDescription, + String[] subCommandGroups, + String subCommand, + String subCommandDescription, + CommandOption[] options) { @Override public final boolean equals(Object o) { - if (!(o instanceof CommandDefinition)) + if (!(o instanceof ExecutableCommandDefinition)) return false; - CommandDefinition other = (CommandDefinition) o; + ExecutableCommandDefinition other = (ExecutableCommandDefinition) o; return other.applicationCommand.equals(this.applicationCommand) && other.subCommandGroups.equals(this.subCommandGroups) && other.subCommand.equals(this.subCommand); @@ -18,16 +28,17 @@ public record CommandDefinition(String applicationCommand, String applicationCom private String[] subCommandGroupNames; private String subCommandName; private String subCommandDescription; + public CommandOption[] options; public Builder() { this.subCommandGroupNames = new String[0]; } - public CommandDefinition build() { + public ExecutableCommandDefinition build() { if (applicationCommandName == null) throw new IllegalArgumentException("applicationCommandName cant be null"); - return new CommandDefinition(applicationCommandName, applicationCommandDescription, subCommandGroupNames, subCommandName, subCommandDescription); + return new ExecutableCommandDefinition(applicationCommandName, applicationCommandDescription, subCommandGroupNames, subCommandName, subCommandDescription, options); } public void setApplicationCommandName(String applicationCommandName) { @@ -50,6 +61,10 @@ public record CommandDefinition(String applicationCommand, String applicationCom this.subCommandDescription = subCommandDescription; } + public void setOptions(CommandOption[] options) { + this.options = options; + } + public String getApplicationCommandName() { return applicationCommandName; } @@ -69,5 +84,9 @@ public record CommandDefinition(String applicationCommand, String applicationCom public String getSubCommandDescription() { return subCommandDescription; } + + public CommandOption[] getOptions() { + return options; + } } }