Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Add support for default sub-commands #9

Closed
wants to merge 3 commits into from

Conversation

jonahseguin
Copy link

This is necessary to allow for the following use case:
You have a base command (in my case, /factions)
You want the root command to display a list of available sub-commands
And you want each individual sub-command to have it's own class.
This allows you to specify the aliases within the @Command annotiation, instead of within the withSubHandler method (and still have the help description be built properly)

@jonahseguin
Copy link
Author

Side note: i couldn't get your custom fork of intake to work in my maven dependencies for this intake-spigot project
so i had to change my dependency to com.sk89q.intake:intake - 4.7-SNAPSHOT
not sure how to fix this

I had to use this:

<dependency>
            <groupId>com.sk89q.intake</groupId>
            <artifactId>intake</artifactId>
            <version>4.2-SNAPSHOT</version>
        </dependency>

instead of this:

<dependency>
            <groupId>li.l1t.intake</groupId>
            <artifactId>intake</artifactId>
            <version>xxyy-82322fd</version>
        </dependency>

Copy link
Owner

@literalplus literalplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default sub-command part looks good, but please open a separate PR for the tab-completion stuff :)

@@ -77,7 +78,12 @@ public CommandBuilder withDispatcherFor(Object handler) {
* @return this instance
*/
public CommandBuilder withSubHandler(Object handler, String... aliases) {
rootGroup.group(aliases).registerMethods(handler);
if (aliases != null && aliases.length > 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer !isEmpty(), it's more semantic / easier to read in general

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants