jqfmt icon indicating copy to clipboard operation
jqfmt copied to clipboard

Some small formatting feature requests

Open somasis opened this issue 1 year ago • 0 comments

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 wondering if you'd be open to adding an option that adds newlines before pipes, rather than after.

currently, with -op pipe,...*, you get something like this

-.data.children |= map_values(select(.data.author == "oilshell") | select(.data.domain == "oilshell.org")
-)
-
+.data.children |= 
+    map_values(select(.data.author == "oilshell") | 
+    select(.data.domain == "oilshell.org"))

but what would be cooler to me would be if it was more like...

-.data.children |= map_values(select(.data.author == "oilshell") | select(.data.domain == "oilshell.org")
-)
-
+.data.children
+    |= map_values(select(.data.author == "oilshell")
+    | select(.data.domain == "oilshell.org"))

even better, I'd really like if it I could get

-.data.children |= map_values(select(.data.author == "oilshell") | select(.data.domain == "oilshell.org")
-)
-
+.data.children
+    |= map_values(
+        select(.data.author == "oilshell")
+            | select(.data.domain == "oilshell.org")
+    )

(though this is probably a completely different formatting option request; -pr for parentheses, or something?)

thanks again for this! :)

(*I actually ran into these wants first with -op pipe,add,sub,mul,div,mod,ne,gt,lt,ge,le,and,or,alt,assign,modify,updateAdd,updateSub,updateMul,updateDiv,updateMod, because I've tended to write my jq scripts very formatted, manually, it seems, but figured it reasonable to pare it down)

somasis avatar Oct 02 '24 18:10 somasis