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

TOML "standard selector syntax" Undocumented #210

Open
slimandslam opened this issue Mar 28, 2022 · 8 comments
Open

TOML "standard selector syntax" Undocumented #210

slimandslam opened this issue Mar 28, 2022 · 8 comments
Labels
documentation Improvements or additions to documentation

Comments

@slimandslam
Copy link

Describe the bug
This is an obvious documentation bug. There is almost zero documentation on the included TOML support

To Reproduce

TOML file:

[STUFF]
mydata = "somestuff"
[MORESTUFF]
mydata2 = "junk"


"Dasel uses a standard selector syntax no matter the data format. "
I want to use your standardized "selectors" to select various
values without having to give an explicit path for everything.
I don't want to translate to an intermediate format like JSON or YAML.

I don't see anything in your documentation about how to do this with TOML

@slimandslam slimandslam added the bug Something isn't working label Mar 28, 2022
@TomWright
Copy link
Owner

What is it you're trying to select?

Here's an example of how you can interact with the above data: https://dasel.tomwright.me/s/59c85b2c-0c35-4b5d-ad2b-56c78ff67f6e

dasel -f file.toml '.STUFF.mydata'

If you don't want to use exact paths you can use the search selector.

If I can get a more explicit example of what you're trying to achieve I can probably be a bit more helpful here.

@TomWright
Copy link
Owner

On a side note, I do agree that more docs on exactly how different formats are interpreted would be helpful.

@slimandslam
Copy link
Author

slimandslam commented Mar 28, 2022

Ok. Here's an example of using the search selector:

[STUFF]
mydata = "somestuff"

[JUNK]
mydata ="other"

without having to know the string "STUFF" or "JUNK", you could do this:

dasel select -m -f data.toml '.(?:-=mydata)'

if you wanted to return the two mydata values.
More TOML examples are needed.

@slimandslam
Copy link
Author

I'd like to be able to select just the node headers. For example:

[STUFF]
mydata = "somestuff"

[JUNK]
mydata ="other"

How do I select just "[STUFF]" and "[JUNK]" (not including mydata) without using the strings "STUFF" and "JUNK"?

@TomWright
Copy link
Owner

For that you can use the keys and indexes selector.

dasel -f file.toml -m '.-'
STUFF
MORESTUFF

Or if you wanted to select just the data without knowing the keys:

dasel -f file.toml -m '.[*]'
mydata = "somestuff"
mydata2 = "junk"

Or this:

dasel -f file.toml -m '.[*].[*]'
somestuff
junk

@slimandslam
Copy link
Author

These are great examples. Please add them to the main documentation. It would probably be useful to have sections for each format you support e.g. a JSON section, a TOML section, a YAML section, a section for going from one format to another, etc.......

@TomWright TomWright added the documentation Improvements or additions to documentation label Apr 6, 2022
@ImportTaste
Copy link

Note that dasel --help produces the following Usage section:

Usage:
  dasel select -f <file> -p <json,yaml> -s <selector> [flags]

... essentially implying there's only json and yaml parsers.

@TomWright
Copy link
Owner

Note that dasel --help produces the following Usage section:

Usage:
  dasel select -f <file> -p <json,yaml> -s <selector> [flags]

... essentially implying there's only json and yaml parsers.

I've just fixed this

@TomWright TomWright removed the bug Something isn't working label Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants