From ad53f315ac6f1893a626afa68adef656465eeb9b Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 28 Aug 2020 21:14:47 +0800 Subject: [PATCH] Fix generated usage for CompositeCommand --- .../console/internal/command/CompositeCommandInternal.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CompositeCommandInternal.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CompositeCommandInternal.kt index e6a96e25c..743126efd 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CompositeCommandInternal.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CompositeCommandInternal.kt @@ -12,6 +12,7 @@ package net.mamoe.mirai.console.internal.command import net.mamoe.mirai.console.command.* +import net.mamoe.mirai.console.command.Command.Companion.primaryName import net.mamoe.mirai.console.command.description.CommandArgumentContext import net.mamoe.mirai.console.command.description.CommandArgumentContextAware import net.mamoe.mirai.message.data.PlainText @@ -228,7 +229,15 @@ internal fun Array.createUsage(b internal fun AbstractReflectionCommand.SubCommandDescriptor.createUsage(baseCommand: AbstractReflectionCommand): String = buildString { if (!baseCommand.prefixOptional) { + append("(") append(CommandManager.commandPrefix) + append(")") + } else { + append(CommandManager.commandPrefix) + } + if (baseCommand is CompositeCommand) { + append(baseCommand.primaryName) + append(" ") } append(names.first()) append(" ")