中文
← Errors

F_SYSTEM_MULTIPLE_MAJOR_COMMANDS

Multiple major commands

The application registers more than one command as its root command.

Updated

Reproduction

Only one command can own invocations that do not start with a command name:

src/app.module.ts
import { CommandMajor, Handler, Module, createApp } from 'func'

@CommandMajor()
class FirstMajor {
  @Handler()
  run() {}
}

@CommandMajor()
class SecondMajor {
  @Handler()
  run() {}
}

@Module({ commands: [FirstMajor, SecondMajor] })
class AppModule {}

createApp(AppModule)

How to fix it

Keep one major command and register the other with a name:

src/app.module.ts
import { Command, CommandMajor, Handler, Module, createApp } from 'func'

@CommandMajor()
class FirstMajor {
  @Handler()
  run() {}
}

@Command('second')
class SecondCommand {
  @Handler()
  run() {}
}

@Module({ commands: [FirstMajor, SecondCommand] })
class AppModule {}

createApp(AppModule)