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

Add --raw / -r option #8

Closed
wants to merge 2 commits into from
Closed

Conversation

kurtbuilds
Copy link
Contributor

@kurtbuilds kurtbuilds commented Aug 26, 2022

Some example usage based on this toml file:

[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "lumache"
authors = [{name = "Graziella", email = "graziella@lumache"}]
dynamic = ["version", "description"]
version = "0.1.0"
 $ toml get pyproject.toml project.version -r
0.1.0
$ toml get pyproject.toml project.version
"0.1.0"
$ toml get pyproject.toml project.version -r
0.1.0
$ toml get pyproject.toml project.name
"lumache"
$ toml get pyproject.toml project.name -r
lumache
$ toml get pyproject.toml project.dynamic
["version","description"]
$ toml get pyproject.toml project.dynamic -r
["version","description"]

@gnprice
Copy link
Owner

gnprice commented Dec 3, 2022

Thanks for sending this!

For cross-reference: the second commit here is about making toml set able to actually edit the file in place, #7. See discussion there about what the interface should be: #7 (comment)

gnprice added a commit that referenced this pull request Dec 4, 2022
No need for this to move ownership of the struct.

Extracted this change from a larger commit contributed by Kurt Wolf
in #8.

Co-authored-by: Kurt Wolf <[email protected]>
@gnprice
Copy link
Owner

gnprice commented Dec 4, 2022

I've just pushed an implementation of --raw/-r, as 3f91f13. I found I wanted to implement it a bit differently from this version -- in particular, to match on the toml_edit::Item to see if it's a string, rather than serialize to JSON first and then match on the serde_json::Value to see if that's a string -- and I also added docs for it in the --help and the README.

I also noticed a useful cleanup in the second commit: making read_parse take a reference, which is a good improvement to the code independently of the other changes there which make it necessary. So I broke that out as its own commit 04e0a6d and pushed that.

Let's leave the rest of the --in-place implementation for a separate PR, after discussing the question at #7 (comment) of whether it should instead become the default behavior.

Thanks again for this contribution! In addition to that cleanup in 04e0a6d, this PR was useful feedback for me that --raw was a feature people do concretely want, so it was a helpful prompt for me to go and implement it 🙂

@gnprice gnprice closed this Dec 4, 2022
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