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

jq command line tool for manipulating toml files? #645

Closed
mcandre opened this issue Jul 27, 2019 · 11 comments
Closed

jq command line tool for manipulating toml files? #645

mcandre opened this issue Jul 27, 2019 · 11 comments
Labels

Comments

@mcandre
Copy link

mcandre commented Jul 27, 2019

Hi, I am curious if there could be a CLI tool similar to jq or yq, for conveniently querying and transforming TOML files?

@mmakaay
Copy link

mmakaay commented Jul 28, 2019

It's a structured data format, so looking at what jq does, it seems to me that similar things could be done for TOML. All it needs is somebody to be inspired to write the tool.

Could you explain what the practical use cases for such tool would be for you? For jq I can imagine a few use cases easily, JSON being a popular data transport format. To me TOML is a configuration format, making such tool less of a natural fit.

One use case that pops to mind for me would be the use of tq (let's call it that ;-) ) from within for example bash scripts, making it possible to use configuration data from TOML files easily from within those scripts. Of course the same goes for running commands from a shell, and for which you want to extract some configuration data from a TOML file.
But for these use cases (which I do find interesting myself), wouldn't need much more than a basic query tool, to fetch values and lists from a TOML file. It would not need transformation capabilities to filter a TOML file and export a transformed / filtered new TOML file.

@pradyunsg
Copy link
Member

There could be -- there isn't one yet AFAIK.

Folks are more than welcome to make one!

@FranklinYu
Copy link

I found this: https://github.com/jamesmunns/tomlq

Hope it helps! Or maybe you can also contribute.

@diraol
Copy link

diraol commented Aug 10, 2020

Just for the record, a tool like that is usefull (for me) to be able to automate tests against toml files. (get/read case)

Or either to automate chances in toml files in a more robust way than sedops would do. :) (set/write case)

So far, "https://crates.io/crates/toml-cli" has been very helpful for test purposes.

@TomWright
Copy link

Another useful tool is this: https://github.com/TomWright/dasel

It supports JSON, YAML and TOML.

@neilmayhew
Copy link

neilmayhew commented Apr 5, 2022

https://github.com/mikefarah/yq/ is widely used as well

@neilmayhew
Copy link

neilmayhew commented Apr 5, 2022

Didn't know that there are actually two yqs, one in Python and one in Go.

Only the Python one works with TOML.

@Alex-ley-scrub
Copy link

@plutonium-239
Copy link

Didn't know that there are actually two yqs, one in Python and one in Go.

Only the Python one works with TOML.

Note that the go one can parse but not write toml, here is the documentation page: https://mikefarah.gitbook.io/yq/usage/toml

@lorrrrrrrenzo
Copy link

@plutonium-239 It's worth nothing this open issue with the Go toml tool: mikefarah/yq#1758

@jthetzel
Copy link

For python, there is now toml-cli ( https://github.com/mrijken/toml-cli ).

I found it helpful for parinsg pyproject.toml files from the terminal.

uv add toml-cli
uv run toml get --toml-path=pyproject.toml project.version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests