scream
scream copied to clipboard
Change handling of multiple matches in atmchange/atmquery
The old syntax was atmchange --all my_param=1 to allow changing all matches of my_param. This had two disadvantages:
- it made scripts harder
- it only allows to change ALL matches in the xml
This PR changes the syntax. Instead of passing a flag, we add ANY in the scoped name. For instance, given this xml:
<root>
<prop1>one</prop1>
<sub>
<prop1>two</prop1>
<prop2 type="integer" valid_values="1,2">2</prop2>
<other>
<prop1>43</prop1>
</other>
</sub>
</root>
we have:
atmchange ANY::prop1=2: changes ALL occurrences ofprop1atmchange sub::ANY::prop1=2: changes all occurrences ofpropthat are nested insidesub, hence skippingroot::prop1.
Basically, using this syntax allows to better scope the area of the XML where "--all" (as it was called before) will act.Use ANY:: in the node name string to allow multiple matches.
Notice that as implemented, ANY does NOT have to match at least one sub-node. In the example above, sub::ANY::prop1 also matches sub::prop1. I considered adding a second keyword, to enforce that ANY would not expand to nothing, something like sub::ANY_CHILD::prop1, which would only match sub::other1::prop1, but it seemed complicated, and I did not see a real need for it.
WARNING: this is not a backward compatible change. If your run script contains the --all flag, it will not work. However, the error message will explain how to change the syntax to comply with the new interface.