Augeas enables you to read and edit your config files in a way which preserves comments and formatting details, allowing humans and programs coexist peacefully when it comes to editing configuration files. More than that, you can map some special structures of the file to special parts of the augeas tree, rather than using the generic INI file parser. See the zypp.conf for example (zypper.conf will have the same structure):
## Option description.
## Default: etc.
# disabledoption = value
## Another option description
another.option = value
With Augeas you can write a lens (the file contents description) which will map such file into a tree like this:
/files/etc/zypp/zypp.conf/main/1/description = "Option description."
/files/etc/zypp/zypp.conf/main/1/description = "Default: etc."
/files/etc/zypp/zypp.conf/main/1/disabledoption = "value"
/files/etc/zypp/zypp.conf/main/2/description = "Another option description."
/files/etc/zypp/zypp.conf/main/2/another.option = "value"
Note the commented node. Augeas has an API for looking for the nodes, getting values from them, setting the values, and finally saving the tree back to the config file.
What does this mean for zypper? Implementing
zypper conf --listis a piece of cake, as well as
zypper conf --set another.option value. Commenting or uncommenting the option is a matter of adding or removing the commented node. Getting the option description for
zypper conf --help some.optionis easy (and maybe it is possible to map the multi-line ## description to a single 'description' node!).
Here is a draft of lens for zypper (it will need comments and further improvements). To try it out you can crete a /etc/zypp/zypper.conf file with contents like the above example, and use the
$ augtool -I /the/dir/with/the/zypper.aug/file
augtool> print /files/etc/zypp/zypper.conf/
/files/etc/zypp/zypper.conf/anon/description = "Configuration file for zypper"
/files/etc/zypp/zypper.conf/anon/description = "Boolean values are 0 1 yes no on off true false"
/files/etc/zypp/zypper.conf/main/1/description = "Whether to use colors"
/files/etc/zypp/zypper.conf/main/1/description = "Default value: autodetected"
/files/etc/zypp/zypper.conf/main/1/colors = "yes"
helpfor other commands, use TAB key for completion, and check also the Augeas home page for more info.
What does this mean for libzypp? Basically the above, with respect to libzypp's files. Currently, you either edit your repos.d/*.repo, locks, credentials, and other files by hand or you leave it to libzypp's frontends, or you at least take care not to write comments in those files, because they will all get removed upon the next change done by libzypp (what we do there is to rewrite the entire files from in-memory data upon saving). This can be easily avoided using Augeas and we can add an editing API for zypp.conf. Plus the bonuses described above.
The library package (libaugeas0) would add 300 kiB of installed size to libzypp's/zypper's dependencies, (which is not little), plus an optional 200 kiB of the official lenses (augeas-lenses), if we decide to use them.
todo: Look at Augeas' error reporting. The user can of course break the structure of the file in a way that the lens can't map it to the tree anymore. If parsing of the file will fail, we need to report why, so that the user can fix it.