Skip to content

Commit

Permalink
Propagate namespace when registering subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
willkroboth committed Jul 3, 2024
1 parent e13eb6d commit ee5907b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Impl setConverted(boolean isConverted) {
// shouldn't be accessing/depending on any of the contents of the current class instance)
@SuppressWarnings({ "unchecked", "rawtypes" })
private static <Impl extends AbstractCommandAPICommand<Impl, Argument, CommandSender>, Argument extends AbstractArgument<?, ?, Argument, CommandSender>, CommandSender>
void flatten(Impl rootCommand, List<Argument> prevArguments, Impl subcommand) {
void flatten(Impl rootCommand, List<Argument> prevArguments, Impl subcommand, String namespace) {
// Get the list of literals represented by the current subcommand. This
// includes the subcommand's name and any aliases for this subcommand
String[] literals = new String[subcommand.meta.aliases.length + 1];
Expand Down Expand Up @@ -243,11 +243,11 @@ void flatten(Impl rootCommand, List<Argument> prevArguments, Impl subcommand) {
rootCommand.withArguments(subcommand.arguments);
rootCommand.executor = subcommand.executor;
rootCommand.subcommands = new ArrayList<>();
rootCommand.register();
rootCommand.register(namespace);
}

for (Impl subsubcommand : subcommand.getSubcommands()) {
flatten(rootCommand, new ArrayList<>(prevArguments), subsubcommand);
flatten(rootCommand, new ArrayList<>(prevArguments), subsubcommand, namespace);
}
}

Expand Down Expand Up @@ -310,7 +310,7 @@ public void register(String namespace) {

// Convert subcommands into multiliteral arguments
for (Impl subcommand : this.subcommands) {
flatten(this.copy(), new ArrayList<>(), subcommand);
flatten(this.copy(), new ArrayList<>(), subcommand, namespace);
}
}

Expand Down

0 comments on commit ee5907b

Please sign in to comment.