Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of repeated sections #73

Open
vaab opened this issue Nov 9, 2020 · 3 comments
Open

Support of repeated sections #73

vaab opened this issue Nov 9, 2020 · 3 comments

Comments

@vaab
Copy link

vaab commented Nov 9, 2020

I'm trying to use crudini on wireguard's config used by wg-quick.

There's a nice example of this file right on the main page: https://www.wireguard.com/

Let's repeat it here:

[Interface]
PrivateKey = yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=
ListenPort = 51820

[Peer]
PublicKey = xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=
AllowedIPs = 10.192.122.3/32, 10.192.124.1/24

[Peer]
PublicKey = TrMvSoP4jYQlY6RIzBgbssQqY3vxI2Pi+y71lOWWXX0=
AllowedIPs = 10.192.122.4/32, 192.168.0.0/16

Notice the multiple [Peer] sections.

When using crudini on this Peer section, I only get the last section. Did I miss something in the docs ?

@pixelb
Copy link
Owner

pixelb commented Nov 9, 2020

More accurately crudini does support multiple sections of the same name,
but will merge the keys in each section, and so only show the last value for each duplicated name.
The TODO mentions we might add support in future for duplicate keys using something like --list=multiname

@martinvonwittich
Copy link

martinvonwittich commented Jun 24, 2024

Support to --set duplicate keys would also be useful for Qalculate's config, which uses the key name keyboard_shortcut for all keyboard shortcuts:

martin@desktop ~/.config/qalculate % grep keyboard_shortcut qalculate-gtk.cfg | head
keyboard_shortcut=65289:0:72
keyboard_shortcut=65470:0:67
keyboard_shortcut=32:4:45
keyboard_shortcut=98:4:59
keyboard_shortcut=102:4:47
keyboard_shortcut=104:4:41
keyboard_shortcut=107:4:40
keyboard_shortcut=109:4:46
keyboard_shortcut=111:4:43
keyboard_shortcut=112:4:39

I would like the ability to add a new keyboard shortcut to this list, e.g. keyboard_shortcut=108:4:74 (but only if this specific key=value pair doesn't exist yet), without accidentally overwriting any of the other keyboard_shortcuts.

@pixelb
Copy link
Owner

pixelb commented Jun 25, 2024

@martinvonwittich this is more aligned with issue #10 I think.
But yes it's a common enough scenario, that crudini should support it with an option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants