johnkerl / miller

Miller is like awk, sed, cut, join, and sort for name-indexed data such as CSV, TSV, and tabular JSON
https://miller.readthedocs.io
Other
9.02k stars 217 forks source link

[feature request] Reuse the format arguments #1650

Open Poshi opened 2 months ago

Poshi commented 2 months ago

Dear @johnkerl,

sometimes I hit the need of using a parameter for a string format more than once:

put '$result = format("{}/{}/{}_{}.ext", $param1, $param2, $param1, $param3)'

it would be shorter and less error prone (when updating the parameters) to be able to refer to the different parameters from the format string. Something like:

put '$result = format("{1}/{2}/{1}_{3}.ext", $param1, $param2, $param3)'

This is just some syntactic sugar to avoid typing, but not a need. If you decide to follow this path, you can also consider more goodies like the ones that some other languages have: use that string inside the "{}" to also define the format to be given to the parameter being substituted. This could be a rabbit hole, so take care if following this path :-)

Thanks