Add the ability to "hide" commands.
This does not yet change how commands are treated, but allows for this to be implemented in the future.
This commit is contained in:
parent
c980adac3b
commit
64fa3430a9
5 changed files with 82 additions and 2 deletions
|
|
@ -226,6 +226,15 @@ public class Command<C> {
|
|||
return this.arguments.get(argument).getDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not the command is hidden
|
||||
*
|
||||
* @return {@code true} if the command is hidden, {@code false} if not
|
||||
*/
|
||||
public boolean isHidden() {
|
||||
return this.getCommandMeta().getOrDefault("hidden", "true").equals("true");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builder for {@link Command} instances. The builder is immutable, and each
|
||||
|
|
@ -437,6 +446,17 @@ public class Command<C> {
|
|||
return builder.handler(command.commandExecutionHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the command should be hidden from help menus
|
||||
* and other places where commands are exposed to users
|
||||
*
|
||||
* @return New builder instance that indicates that the constructed command should be hidden
|
||||
*/
|
||||
@Nonnull
|
||||
public Builder<C> hidden() {
|
||||
return this.meta("hidden", "true");
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a command using the builder instance
|
||||
*
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ public final class StandardParameters {
|
|||
* Command completions
|
||||
*/
|
||||
public static final ParserParameter<String[]> COMPLETIONS = create("completions", TypeToken.of(String[].class));
|
||||
/**
|
||||
* The command should be hidden from help menus, etc
|
||||
*/
|
||||
public static final ParserParameter<Boolean> HIDDEN = create("hidden", TypeToken.of(Boolean.class));
|
||||
|
||||
private StandardParameters() {
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue