tool for modifying conf/ini files #224
Labels
No Label
bugfix
cleanup
discussion
documentation
doing
done
feature
improvement
packaging
Stale
testing
TODO
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: ungleich-public/cdist#224
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Created by: lloyd
I wonder if there is a type for parsing/modifying ini/.conf files?
In 20 minutes of looking I haven't found anything beyond the
__key_value
type, the__line
type, and__block
. None of this is a good fit.A case this specifically this would be useful for is in toggling a value in an .ini file where that value was repeated multiple times in distinct sections:
I'd like to say something like:
closed
Created by: toupeira
It would be worth looking into Augeas which provides automated editing of all sorts of configuration files, you could use
augtool
to implement a generic__augeas
type similar to the one available in Puppet.Created by: telmich
I suggest nl instead of cat -n (-n is not posix) at first glance. I think there are some issues in your proposal, but it is actually hard to comment without a pull request. Generally speaking I'd check if you need to create the section as well (i.e. if it does not exist).
So in short, I suggest to make a PR as a basis for the discussion - even if we have to rewrite it several times
Created by: lloyd
(if this looks acceptable as a first implementation, I'll write docs and open a pull request)
Created by: lloyd
Interesting. I can look into making the implementation a bit more elegant/idiomatic. For now, I've gotten a first version written and am using it in one of my projects.
I really like the idea of using an explorer, performing the manipulation and diff on the client machine, and then transferring a patch! Writing escaped shell in a heredoc is rather cumbersome :).
Created by: telmich
Lloyd,
a pointer that may help you: awk can do tracking of sections easily like
this:
No need to use awk - but I think it can easily achieve what you want :-)
Daniel suggested to use an explorer to get the whole ini file, create a
new one, copy over the diff and use patch to apply the changes. We could
do it like that or use the __file type to transfer the whole file.
Cheers,
Nico
Lloyd Hilaiel [Mon, Feb 10, 2014 at 08:14:00AM -0800]:
PGP key: 7ED9 F7D3 6B10 81D7 0EC5 5C09 D7DC C8E4 3187 7DF0
Created by: lloyd
ok, I must have not understood quite how
object_ids
work.I like the syntax you propose, and will try to craft something. Working draft of the implementation looks something like this: https://gist.github.com/lloyd/8918659
Created by: telmich
I'd definitely recommend against this syntax, as it enforces (pseudo)
structure where it is not needed and can be ambiguous.
I would also recommend to take the object_id as a filename, but allow
the user to specific the filename using --file as well (for setting
multiple entries in multiple locations). For me, it could look like this:
This is just an idea, though.
Cheers,
Nico
Lloyd Hilaiel [Mon, Feb 10, 2014 at 06:54:06AM -0800]:
PGP key: 7ED9 F7D3 6B10 81D7 0EC5 5C09 D7DC C8E4 3187 7DF0
Created by: lloyd
ok, cool. I wonder if the
__object_id
should actually include the filename and property. If it did not, it would not be possible to change the same property in two files.So something like this?
Created by: telmich
Not yet, but you are welcome to write one - I think it would be beneficial and could be accepted upstream.