You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I often use dasel to mangle test data, and would like to be able to vary the values that I'm puting into the output.
Describe the solution you'd like
I'd like to be able to specify a node selector string in the value.
Where -V (or some other flag) tells dasel to run the query on the current node and use the result as the value. This example would set the attribute "Name": "Item <index>" for each Item object in the Items array.
Describe alternatives you've considered
If the set is large enough, I'd write a Ruby or awk script. My test sets tend to be small, so I usually just edit them by hand.
I also considered using --merge-input-documents, but I don't believe it'd replace the existing objects -- just add to them. In any case, it'd be fairly involved to create the merge document, and possibly more trouble than writing code to modify the data.
Being able to insert values relative to the document would, I think, be a more interesting generally, but for my use case it'd be sufficient if I could call a program (or shell function) for each node. I could generate values externally (if there was a mechanism for it), but (as I said) I imagine it might be more valuable in general to be able to, e.g., set a value from some permutation of another attribute in the node. E.g., set the Name attribute to the equivalent of template-ish "{{.FirstName}} {{.LastName}}"
To be clear, I like the direction you're thinking in. It's frankly better than what I was imagining.
I believe this is already achievable with the updated query/selector syntax in dasel V3.
We're many years later so I will close this now, but any problems please create a new issue.
Activity
TomWright commentedon Mar 6, 2022
This is an interesting use-case.
Note to myself - This could be achieved with the
--formatflag if the selector was made available in the format templates here:dasel/output_formatter.go
Line 63 in b779b88
xxxserxxx commentedon Mar 8, 2022
Being able to insert values relative to the document would, I think, be a more interesting generally, but for my use case it'd be sufficient if I could call a program (or shell function) for each node. I could generate values externally (if there was a mechanism for it), but (as I said) I imagine it might be more valuable in general to be able to, e.g., set a value from some permutation of another attribute in the node. E.g., set the
Nameattribute to the equivalent oftemplate-ish"{{.FirstName}} {{.LastName}}"To be clear, I like the direction you're thinking in. It's frankly better than what I was imagining.
TomWright commentedon Dec 10, 2025
I believe this is already achievable with the updated query/selector syntax in dasel V3.
We're many years later so I will close this now, but any problems please create a new issue.