Skip to content

Allow flattening options in objects #114

@arnetheduck

Description

@arnetheduck

Consider the configuration of a typical metrics server:

      metricsEnabled* {.
        desc: "Enable the metrics server"
        defaultValue: false
        name: "metrics" .}: bool

      metricsAddress* {.
        desc: "Listening address of the metrics server"
        defaultValue: defaultAdminListenAddress
        defaultValueDesc: $defaultAdminListenAddressDesc
        name: "metrics-address" .}: IpAddress

      metricsPort* {.
        desc: "Listening HTTP port of the metrics server"
        defaultValue: 8008
        name: "metrics-port" .}: Port

There are three options here that are related but not the same - such metrics would conveniently be packed into a MetricsConf object that could be reused in various configurations:

type MyConf = object
  metrics {.flatten.}: MetricsConf

MyConf would then traverse metrics as if its options were "top-level" options in MyConf.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions