Skip to content

feat: support for appending to array at path#11

Merged
rmehri01 merged 4 commits intomainfrom
rmehri01/append-array-at-path
Jan 8, 2025
Merged

feat: support for appending to array at path#11
rmehri01 merged 4 commits intomainfrom
rmehri01/append-array-at-path

Conversation

@rmehri01
Copy link
Contributor

@rmehri01 rmehri01 commented Jan 7, 2025

  • add /[] syntax to path that will append instead of overwriting the value at the path

For example, if we have a pyproject.toml with the following contents:

[tool.uv.sources]
torch = [{ index = "foo", marker = "platform_system == 'Windows'" }]

Then applying:

jq -c -n '[{op: "add", table_header_path: "tool/uv/sources", path: "torch/[]", value: "{\"index\": \"pytorch-cpu\"}"}]' | cargo run -- --path pyproject.toml

Will result in the following contents in pyproject.toml:

[tool.uv.sources]
torch = [{ index = "foo", marker = "platform_system == 'Windows'" }, { index = "pytorch-cpu" }]
  • also fix some clippy lints

@rmehri01 rmehri01 force-pushed the rmehri01/append-array-at-path branch from 433ee72 to cbe0300 Compare January 7, 2025 22:18
Copy link
Contributor

@blast-hardcheese blast-hardcheese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic. Thanks for the back and forth, I think this DX is solid, and will continue to offer opportunities for further extensibility (path: foo/bar/[]/baz/blix as an example).

Thank you!

@rmehri01 rmehri01 merged commit 3662fd5 into main Jan 8, 2025
@rmehri01 rmehri01 deleted the rmehri01/append-array-at-path branch January 8, 2025 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants