中文
← Errors

F_SYSTEM_DUPLICATE_OPTION_TOKEN

Duplicate option token

A field, Module option, or action option claims the same token at one command node.

Updated

Reproduction

Long option names and short aliases must be unique at a command node. The generated --no-<name> form of a negatable flag also participates in collision checks:

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

@CommandMajor()
class BuildCommand {
  @Flag('config')
  useConfig = false

  @Value('config')
  config = ''

  @Handler()
  run() {}
}

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

createApp(AppModule)

How to fix it

Rename one conflicting token or remove the duplicate declaration:

src/build.command.ts
@CommandMajor()
class BuildCommand {
  @Flag('use-config')
  useConfig = false

  @Value('config')
  config = ''

  @Handler()
  run() {}
}

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

createApp(AppModule)