Elektra  0.8.17
Plugin: spec

The spec plugin is a global plugin that copies metadata from the spec-namespace to other namespaces using their key names as globbing expressions. Globbing resembles regular expressions. They do not have the same expressive power, but are easier to use. The semantics are more suitable to match path names:

The plugin copies the metadata of the corresponding spec key to every matching key in the other namespaces.

The spec plugin also provides basic validation and struct checking.

It supports:

CONFIGURATION

ACTIONS

CONFLICTS

BASIC CONFIGURATION

conflict/set and conflict/get are used to specify what actions should be taken on conflicts. e.g. conflict/get = ERROR yields an error on every conflict.

PER CONFLICT CONFIGURATION

Actions can also be specified on a per conflict basis. Those actions take precedence over basic configuration options.

Examples: ``` conflict/get/member = WARNING conflict/set/range = ERROR ```

PER KEY CONFIGURATION

Actions can also be specified per-key. Those will take precedence over basic and per-conflict configurations.

Example: ``` spec/test/# conflict/get/member = INFO ```

EXAMPLES

Ini files can be found in /examples/spec which should be PWD so that the example works:

    cd ~e/examples/spec
    kdb global-mount        # mounts spec plugin by default
    kdb mount $PWD/spec.ini spec ni
    kdb mount $PWD/spectest.ini /testkey ni
    kdb export /testkey ni     # note: spec can only applied on cascading access

With spec mount one can use (in this case battery.ini needs to be installed in kdb file spec (this should be preferred on non-development machines so that everything still works after the source is removed):

    cp battery.ini $(dirname $(kdb file spec))
    kdb mount battery.ini spec/example/battery ni
    kdb spec-mount /example/battery
    kdb lsmeta /example/battery/level    # we see it has a check/enum
    kdb getmeta /example/battery/level check/enum    # now we know allowed values
    kdb set /example/battery/level low   # success, low is ok!
    kdb set /example/battery/level x     # fails, not one of the allowed values!


    cp openicc.ini $(dirname $(kdb file spec)) 
    kdb mount openicc.ini spec/freedesktop/openicc ni
    kdb spec-mount /freedesktop/openicc

    kdb ls /freedesktop/openicc # lets see the whole configuration
    kdb export spec/freedesktop/openicc ni   # give us details about the specification
    kdb lsmeta /freedesktop/openicc/device/camera/#0/EXIF_serial   # seems like there is a check/type
    kdb set "/freedesktop/openicc/device/camera/#0/EXIF_serial" 203     # success, is a long
    kdb set "set "/freedesktop/openicc/device/camera/#0/EXIF_serial" x   # fails, not a long