From 9a87497a06a08b72059d1269976c45499f7c282f Mon Sep 17 00:00:00 2001 From: "jiahua.liu" Date: Mon, 25 May 2020 14:53:24 +0800 Subject: [PATCH] CompositeCommand usage --- .../net/mamoe/mirai/console/command/Command.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt index d9417c6bd..4f8ce7b0e 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt @@ -295,3 +295,20 @@ internal inline fun KAnnotatedElement.hasAnnotation(): internal inline fun KClass.getInstance():T { return this.objectInstance ?: this.createInstance() } + + +fun main(){ + val mute = object:CompositeCommand( + TestCommandOwner, + "mute" + ){ + @SubCommand("add") + fun CommandSender.onMute1(@Name("参数名1") target: String):Boolean{ + return true + } + } + + mute.subCommands + + println(mute.usage) +}