jqfmt
jqfmt copied to clipboard
like gofmt, but for jq
hi! thanks for this awesome piece of software, I've been looking for a formatter for my `jq` scripts for a good while now. it works really well, but I was...
I have a file named `count_query.jq` with the following contents: ```jq def count_uplinks(leaves): reduce leaves[] as $leaf ({}; .[$leaf.leaf_switch] += 1); .[0] | map( map_values( count_uplinks(.) ) ) ``` Here's...
at the time of writing, [this repo is mit-licensed per readme](../blob/8fc6f864c295e6bd6b08f36f503b3d809270da61/README.md#license), [but `LICENSE.md` is missing](../blob/8fc6f864c295e6bd6b08f36f503b3d809270da61/LICENSE.md), which this pr wants to add
Input ```jq map(select(has("resource")) | .resource.github_repository | to_entries | map(.value | map(.name))) | flatten[] ``` Command ```sh jqfmt -ar -ob -op pipe,comma,add,sub,mul,div,mod,eq,ne,gt,lt,ge,le,and,or,alt,assign,modify,updateAdd,updateSub,updateMul,updateDiv,updateMod,updateAlt ``` Output ``` map(select(has("resource")) | .resource.github_repository | to_entries |...
https://treefmt.com/latest/reference/formatter-spec/ Basically, accept files as arguments, and write change back to those files in an idempotent way.