annotation

LavinMQ::Config::CliOpt

Marks a config property as settable from a command-line argument.

Positional arguments (in order):

  1. short flag with optional value placeholder, e.g. "-p PORT" (use "" when the option has no short flag)
  2. long flag with optional value placeholder, e.g. "--amqp-port=PORT"
  3. description shown in --help
  4. optional Proc(String, T) that converts the raw argument to the property's type. When omitted, the property's own type is used and the value is converted by the matching Config#parse_value overload.

Named arguments:

  • section: groups the flag under a heading in --help, one of "options", "bindings", "tls" or "clustering". Defaults to "options".
  • deprecated: a complete warning message, printed verbatim, when the flag is used. To forward the old value to a replacement, define a setter (and no getter) on the deprecated property; an option with no replacement defines no setter and its value is dropped after the warning.

Parsed by Config#parse_cli. CLI args take precedence over EnvOpt and IniOpt.

@[CliOpt("-p PORT", "--amqp-port=PORT", "AMQP port to listen on (default: 5672)", section: "bindings")]
property amqp_port = 5672

A deprecated flag whose value is forwarded to a replacement: declare the instance variable (not a property) and define only the setter, which assigns to the new property.

@[CliOpt("", "--default-password=HASH", "(Deprecated) Hashed password for default user",
  section: "options", deprecated: "--default-password is deprecated, use --default-password-hash")]
@default_password : Auth::Password::SHA256Password = DEFAULT_PASSWORD_HASH

def default_password=(value)
  @default_password_hash = value # forward to the replacement
end