Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for appending to array at path #11

Merged
merged 4 commits into from
Jan 8, 2025

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
2 checks passed
@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