Skip to content

Commit 49f4912

Browse files
committed
Add ability to get a short description from the registrar
1 parent fe31fe6 commit 49f4912

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/main/java/org/spongepowered/api/command/Command.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030
import org.spongepowered.api.Sponge;
3131
import org.spongepowered.api.command.exception.ArgumentParseException;
3232
import org.spongepowered.api.command.exception.CommandException;
33+
import org.spongepowered.api.command.manager.CommandMapping;
3334
import org.spongepowered.api.command.parameter.ArgumentReader;
3435
import org.spongepowered.api.command.parameter.CommandContext;
3536
import org.spongepowered.api.command.parameter.Parameter;
3637
import org.spongepowered.api.command.parameter.managed.Flag;
38+
import org.spongepowered.api.command.registrar.CommandRegistrar;
3739
import org.spongepowered.api.command.registrar.tree.CommandTreeNode;
3840
import org.spongepowered.api.command.registrar.tree.CommandTreeNodeTypes;
3941
import org.spongepowered.api.event.Cause;
@@ -130,7 +132,11 @@ static Builder builder() {
130132
/**
131133
* Gets a short one-line description of this command.
132134
*
133-
* <p>The help system may display the description in the command list.</p>
135+
* <p>The help system may display the description in the command list, or
136+
* in any other function that displays a command list. It is therefore
137+
* recommended that any description here is kept very short.</p>
138+
*
139+
* @see CommandRegistrar#shortDescription(CommandCause, CommandMapping)
134140
*
135141
* @param cause The {@link CommandCause} of the help request
136142
* @return A description
@@ -157,6 +163,8 @@ static Builder builder() {
157163
* <p>The help system may display this message when a source requests
158164
* detailed information about a command.</p>
159165
*
166+
* @see CommandRegistrar#help(CommandCause, CommandMapping)
167+
*
160168
* @param cause The {@link Cause} of the help request
161169
* @return A help text
162170
*/

src/main/java/org/spongepowered/api/command/manager/CommandManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ public interface CommandManager {
164164
*/
165165
Set<String> knownAliases();
166166

167+
/**
168+
* Gets all the {@link CommandMapping mappings} known to this command
169+
* manager.
170+
*
171+
* @return The known mappings.
172+
*/
173+
Set<CommandMapping> knownMappings();
174+
167175
/**
168176
* Gets a {@link Collection} of {@link PluginContainer}s with commands
169177
* registered.

src/main/java/org/spongepowered/api/command/registrar/CommandRegistrar.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,30 @@ CommandMapping register(
142142
List<CommandCompletion> complete(CommandCause cause, CommandMapping mapping, String command, String arguments) throws CommandException;
143143

144144
/**
145-
* Returns help text for the invoked command.
145+
* Returns a short description for the invoked command, if one is
146+
* available.
147+
*
148+
* <p>A good short description is not necessarily help, rather, it should
149+
* be a short description of the command's function. This short description
150+
* <strong>may</strong> also be part of the
151+
* {@link #help(CommandCause, CommandMapping) standard help} for the
152+
* function.</p>
153+
*
154+
* <p>It is recommended that any description here is kept very short as such
155+
* a description may be used in a command listing.</p>
156+
*
157+
* @param cause The {@link CommandCause} that caused the command to be
158+
* executed
159+
* @param mapping The {@link CommandMapping} that is associated with the
160+
* command
161+
* @return The help, if any
162+
*/
163+
default Optional<Component> shortDescription(final CommandCause cause, final CommandMapping mapping) {
164+
return Optional.empty();
165+
}
166+
167+
/**
168+
* Returns help text for the invoked command, if one is available.
146169
*
147170
* @param cause The {@link CommandCause} that caused the command to be
148171
* executed

0 commit comments

Comments
 (0)