$darkmode
Elektra 0.11.0
|
Export a subset of the KDB as C code which creates a KeySet (ksNew(<number of keys>, keyNew(...), ...)
). This can be useful for generating test data or help to generate code for already defined configuration data.
The output can be used in C code for generating KeySets and the keys inside them. So one use case is to extract a part of the KDB and copy the generated code to create the exported part of the KDB programmatically, e.g. for another Elektra installation.
It can also be useful if you develop your own application and first create the necessary keys manually. Then you can export them from the KDB and just paste the generated code in the right place of the codebase of your application.
Please note that if you use this plugin for creating a mountpoint (e.g. by calling
kdb mount <filename> <key> c
), only the content written by the lastkdbSet (...)
which includes the mountpoint will be inside the file. If you callkdbSet (...)
for such a mountpoint, the previous content of the file is erased.This is because the c plugin is implemented as a write-only plugin. It's recommended to only use it for exporting parts of the KDB by calling
kdb export <parent key>
.
In this example, we add some keys and metakeys to the KDB and export them with the c plugin. The output can directly be used inside C source code which uses Elektra.