Open
Conversation
Member
|
You'll need to look into the submission guidelines regarding commit formatting, etc. |
c1e751f to
075d2cb
Compare
92f0747 to
bf0a598
Compare
56181fc to
0cb0626
Compare
f1c8b3c to
db733c0
Compare
This pull request implements preservation of comments in configuration
files.
Comment lines before an entry, and the comment at the end of an entry
are considered to be associated with that entry.
Example:
# this comment line is associated with section
# this comment line is associated with section
config type 'section' # this comment is associated with section
# this comment line is associated with opt
# this comment line is associated with opt
option opt 'val' # this comment is associated with opt
# this comment line is not associated with any entry
Wih option -D, uci works as before and strips comments.
The following commands have enhanced behaviour:
* uci import
preserves comments of unchanged configuration entries, and imports
entries with their associated comments
* uci export
exports entries with their associated comments
* uci commit
preserves comments of unchanged configuration entries when
committing changes with uci commands 'add', 'delete', 'set',
'add_list', and/or 'del_list'.
* uci get '<config>.<section>' '#'
shows the section comment
* uci get '<config>.<section>.<option> '#'
shows the option comment
* uci set '<config>.<section>=<value>' '<comment>'
sets the section value and comment
* uci set '<config>.<section>.option=<value>' '<comment>'
sets the option value and comment
* uci add_list '<config>.<section>.option=<value> '<comment>'
adds a list entry with value and comment
* uci changes
also shows comments
* uci show
does not show comments
* uci batch
supports the above commands
Features:
* Comments are auto-indented if preserved, set or added.
* The new delta file format is both backward compatible and forward
compatible. Older uci versions interpret the addition in the new
format as comment and ignore it.
* Comments at the end of the file are not preserved because they do
not belong to an entry.
An example of a result: the above example after and option 'opt2' has
been added with a comment:
# this comment line is associated with section2
# this comment line is associated with section2
config type section2 # this comment is associated with section 2
# this comment line is associated with opt
# this comment line is associated with opt
option opt 'val' # this comment is associated with opt
# comment line for new option 'opt2'
option opt2 'val2'
Signed-off-by: Bastiaan Stougie <wififreedom2026@protonmail.com>
db733c0 to
7141f01
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request implements preservation of comments in configuration files.
Comment lines before an entry, and the comment at the end of an entry are considered to be associated with that entry.
Example:
Wih option
-D, uci works as before and strips comments. The following commands have enhanced behaviour:uci importpreserves comments of unchanged configuration entries, and imports entries with their associated commentsuci exportexports entries with their associated commentsuci 'commitpreserves comments of unchanged configuration entries when committing changes with uci commands 'add', 'delete', 'set', 'add_list', and/or 'del_list'.uci get '<config>.<section>' '#'shows the section commentuci get '<config>.<section>.<option> '#'shows the option commentuci set '<config>.<section>=<value>' '<comment>'sets the section value and commentuci set '<config>.<section>.option=<value>' '<comment>'sets the option value and commentuci add_list '<config>.<section>.option=<value> '<comment>'adds a list entry with value and commentuci changesalso shows commentsuci showdoes not show commentsuci batchsupports the above commandsFeatures:
I've added lots of shunit2 tests to verify the implementation.
An example of a result: the above example after and option 'opt2' has been added: