EN
← 错误索引

F_SYSTEM_MULTIPLE_DEFAULT_HANDLERS

存在多个默认处理器

同一命令声明了多个不带 flag 或 path 的 @Handler。

更新于

复现

func 无法在多个回退方法之间做出选择:

src/build.command.ts
import { CommandMajor, Handler, Module, createApp } from 'func'

@CommandMajor()
class BuildCommand {
  @Handler()
  build() {}

  @Handler()
  rebuild() {}
}

@Module({ commands: [BuildCommand] })
class AppModule {}

createApp(AppModule)

如何修复

只保留一个默认处理器,并为其他处理器添加 flag 或 path:

src/build.command.ts
@CommandMajor()
class BuildCommand {
  @Handler()
  build() {}

  @Handler({ flag: 'rebuild' })
  rebuild() {}
}

@Module({ commands: [BuildCommand] })
class AppModule {}

createApp(AppModule)