中文
← Errors

F_SYSTEM_MULTIPLE_DEFAULT_HANDLERS

Multiple default handlers

One command declares more than one @Handler without a flag or path.

Updated

Reproduction

func cannot choose between multiple fallback methods:

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)

How to fix it

Keep one default handler and give every additional handler a flag or path:

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

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

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

createApp(AppModule)