Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: 支持CompositeCommand间组合 #2857

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

Conversation

hundun000
Copy link
Contributor

#2125 误操作关闭,继续在此开发;
resolve #1804

@hundun000
Copy link
Contributor Author

hundun000 commented Aug 20, 2024

参考CommandReflector抽出SubCommandReflector,其将解析这样一种树:

  • fun findSubCommands()对应所有根到叶子的路径,一部分(val fromMemberFunctions)是直接是叶子,一部分(val fromMemberProperties)是来自子树的SubCommandGroup::overloads
  • 递归的,SubCommandGroup::overloads由其SubCommandReflector计算。

抽出SubCommandAnnotationResolver<T>,其决定树的指令路径特点:

  • T作为当前节点
  • 某些KFunction可作为叶子节点,其名字插入指令路径的末尾
  • 某些KProperty可作为非叶子节点,影响指令路径

则对于CompositeCommandSubCommandAnnotationResolver,其特点是:

  • Command作为当前节点
  • @SubCommand用于定义一个叶子节点,其名字插入指令路径的末尾
  • @FlattenSubCommands用于定义一个非叶子节点,不影响指令路径

新增GroupedCommandSubCommandAnnotationResolver,其特点是:

  • SubCommandGroup作为当前节点
  • @SubCommand用于定义一个叶子节点,其名字插入指令路径的末尾
  • @FlattenSubCommands用于定义一个非叶子节点,不影响指令路径

衍生性质:

  • 经过任意深度的@FlattenSubCommands到达的叶子节点,由于途中的树枝不影响指令路径,故等价于其在树根。

#2125 有过提议但不在本次PR处理计划内的性质,未来可另行新增,与本PR不冲突:

  • 进一步地,允许@SubCommand用于定义一个非叶子节点,其名字插入指令路径的对应位置

@hundun000 hundun000 marked this pull request as ready for review August 21, 2024 06:54
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

支持 多个主指令名相同的CompositeCommand注册的SubCommand均生效
1 participant