dasel icon indicating copy to clipboard operation
dasel copied to clipboard

TOML "standard selector syntax" Undocumented

Open slimandslam opened this issue 4 years ago • 8 comments

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 avatar Mar 28 '22 03:03 slimandslam

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 avatar Mar 28 '22 13:03 TomWright

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

TomWright avatar Mar 28 '22 13:03 TomWright

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 avatar Mar 28 '22 20:03 slimandslam

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"?

slimandslam avatar Mar 29 '22 19:03 slimandslam

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

TomWright avatar Mar 30 '22 13:03 TomWright

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.......

slimandslam avatar Mar 30 '22 19:03 slimandslam

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.

God-damnit-all avatar Oct 03 '22 03:10 God-damnit-all

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 avatar Oct 03 '22 11:10 TomWright