Skip to content

Some small formatting feature requests #6

@somasis

Description

@somasis

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions