.props parsing with profiles

12 views
Skip to first unread message

BloodySmartie

unread,
Sep 25, 2015, 5:00:32 AM9/25/15
to Jodders
Hi there!

I was happily building a little config file that looks like this:



#emergency addresses
[emergency<1>]
[emergency<3>]
[emergency<3>]
address=wa...@fire.io

#server ips
[servers<myserver>]
ip=10.10.10.1

[servers<anotherserver>]
ip=10.10.10.2



Of course, the real file is a bit more complex. I've thought that it's pretty cool to parse those settings using profiles when there were just the [emergency]-sections. But then I added the servers and saw, that my thoughts where wrong because I fetched the list of profiles to parse IPs using getAllProfiles(), of course. Also of course, that didn't work anymore.

The question is: Can I get somehow a list of profiles that are connected to the name of a section? In this case, for example, getProfilesFor("servers") would return ["myserver","anotherserver"].

Kind Regards,

David


Jodders

unread,
Sep 25, 2015, 6:12:11 AM9/25/15
to Jodders
Of course it is possible :))) Just use method: getProfilesFor() :)))

Ok, Im cheating here :) This method is available since... now:


The only difference from what you said is that provided profile name may be either a full name, or a wildcard, so you would use:

getProfiles("servers.*")

since the profiles can be set anywhere in the key name.

Would you be so kind to check this commit and see if this is what you need ;)

BloodySmartie

unread,
Sep 25, 2015, 6:15:01 AM9/25/15
to Jodders
My god, I wish everybody would offer such a great, fast support! Thank you very much, that's really a great help. Is it okay if I answer on monday? I'll not be in the office anymore until Monday around 7. First thing to do will be to check your solution - I promise!

Jodders

unread,
Sep 25, 2015, 6:17:24 AM9/25/15
to Jodders
:) Sure, take your time - let me know when its ok for you, so we can publish the snapshot on bintray with other improvements.

BloodySmartie

unread,
Sep 28, 2015, 3:01:58 AM9/28/15
to Jodders
Just as I promised, I've done the tests and I'm able now to perfectly work with profiles like I intended to. I want to thank you very much, again. You're offering a great support since I've got to know Jodd a few years ago.
Reply all
Reply to author
Forward
0 new messages