I don't have an opinion one way or the other, but one aspect seems evident to me:
option comment or list comment would have the benefit of the comment being available to the UCI system, for display or even editing in LuCI.
It doesn't happen very often, but occasionally I am slightly disappointed about not being able to leave non-operational comments with entries in the UI. Names are not always descriptive, and oftentimes missing at all (see the "IPv* Routes" table for example). And it would be nice to add comments to configuration entries that are not exclusively visible in the raw config files.
In my book, code does not get committed without the associated (unit) tests, because if it has not been proven to work, it does not work and can't be maintained.
Also, comments are IMO required, not optional. Because there were hardly any comments in the existing code, I have kept them to the essentials to follow the coding style. I'm certainly prepared to add more comment.
However, I'm only going to do so if someone who actually has a say in what is merged into the uci repo reviews the code properly on github.
I will retract my pull request. The way to go is not by modifying uci and libuci.
One of the technical problems I encounter is that the libuci API is too exposed to make non-breaking changes: all structs can be manipulated at will by clients, and modifying a struct breaks binary compatibility, requiring the client to recompile its code.
There appears to be much opposition to expand a tool that strives to be as lean and mean as possible for embedded systems.
So it seems that OpenWrt wil not support '#'-style comments in config files, until the current uci and libuci can be replaced by something more flexible. I will work on that instead, no results promised.
I still use the lua based luci (updated to use luaJson and ubus), the luci cbi model has hooks on:commit(), on:after_commit(), on:before_commit() .. etc
If only these hooks where still available in the modern luci/uci system... life would be a dream
That would take me a long while to implement, because I don't know enough about lua. I have found the lua wrapper in the uci repository, but I couldn't quickly understand enough of the code to add an interface for the comments to it.
I was also not sure if it was still actively in use or a relic. I understand that luci used to interface with libuci through the lua wrapper, but luci no longer uses it as far as I can see.
no, as far as i know the successor doesn't include such hooks. I have no idea what it would take to pull off using the ucode approach.
The current state is relic, but I am working on updating the luci lua api by converting it to json based. I have a written a lua C library (luaJson) that can handle JSON and expose it to lua and the lua c api .. and in turn ubus-lua and uhttpd-lua.
Lua is already plumbed into all the core models, so its a matter of updating these existing lua modules to use luaJson format and adding hooks for the ubus-lua module.
The timeline to completion ? ... when its finished I am only one dev and time is precious.
Lua scripting api is like a much simpler version of JS really, only totally portable, with a very small footprint ~260kb. the real power is hidden in the lua c api , most notably, the ability to wrap/bind and expose virtually any existing c library.
The beauty of these hooks is that they just call your callbacks ..ie
m.on:before_commit()
stash_my_comments(m) --call the lua script, a library function , or bound c function
do_something_else(o.somevalue)
end
m.on:commit()
reapply_comments(m)
end
Note, these hooks go in the cbi models, so the map (uci config) is already exposed to the hooks and the callbacks