summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2021-02-26 16:15:11 -0500
committerBen Culkin <scorpress@gmail.com>2021-02-26 16:15:11 -0500
commite55cb9852a106cff26517d7d1e85bc4b149884f3 (patch)
tree2e5d8b8d1e4ec8a5893cc2372e84aade218e648a /base
parentd7b2e924d762e66b3f2be76242ee761e90113a8c (diff)
Update
Diffstat (limited to 'base')
-rw-r--r--base/src/main/java/bjc/utils/cli/Command.java37
1 files changed, 27 insertions, 10 deletions
diff --git a/base/src/main/java/bjc/utils/cli/Command.java b/base/src/main/java/bjc/utils/cli/Command.java
index 5f4a65b..68351bf 100644
--- a/base/src/main/java/bjc/utils/cli/Command.java
+++ b/base/src/main/java/bjc/utils/cli/Command.java
@@ -7,15 +7,6 @@ package bjc.utils.cli;
*/
public interface Command {
/**
- * Create a command that serves as an alias to this one
- *
- * @return A command that serves as an alias to this one
- */
- default Command aliased() {
- return new DelegatingCommand(this);
- };
-
- /**
* Get the handler that executes this command
*
* @return The handler that executes this command
@@ -28,7 +19,16 @@ public interface Command {
* @return The help entry for this command
*/
CommandHelp getHelp();
-
+
+ /**
+ * Create a command that serves as an alias to this one
+ *
+ * @return A command that serves as an alias to this one
+ */
+ default Command aliased() {
+ return new DelegatingCommand(this);
+ };
+
/**
* Check if this command is an alias of another command
*
@@ -37,4 +37,21 @@ public interface Command {
default boolean isAlias() {
return false;
}
+
+ /**
+ * Create a new basic command.
+ *
+ * @param summary The summary of the command. This is used as a short help
+ * message displayed when listing commands.
+ * @param description The description of the command. This is what is shown
+ * when the detailed help for a command is asked for.
+ * @param handler The implementation for the command.
+ *
+ * @return A command with the given implementation.
+ */
+ static Command from(
+ String summary, String description, CommandHandler handler)
+ {
+ return new GenericCommand(handler, summary, description);
+ }
}