中文
← Errors

F_SYSTEM_DUPLICATE_OPTION_TOKEN

Duplicate option token

Multiple fields, sub-options, handler flags, or handler paths claim the same token in one command.

Updated 2 weeks ago

Reproduction

All option names, aliases, handler flags, and handler paths must be unique within a command:

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

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

  @Value({ name: 'config' })
  config = ''

  @Handler()
  run() {}
}

new Container([BuildCommand])

How to fix it

Rename one conflicting token or remove the duplicate declaration:

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

  @Value({ name: 'config' })
  config = ''

  @Handler()
  run() {}
}

new Container([BuildCommand])