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

Implement Map Operator #6

Open
jihchi opened this issue Oct 19, 2021 · 1 comment
Open

Implement Map Operator #6

jihchi opened this issue Oct 19, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@jihchi
Copy link
Owner

jihchi commented Oct 19, 2021

Reference: https://github.com/kdl-org/kdl/blob/1.0.0/QUERY-SPEC.md#map-operator

Modified from QUERY-SPEC.md)

$ cat example.kdl
package {
    name "foo"
    version "1.0.0"
    dependencies platform="windows" {
        winapi "1.0.0" path="./crates/my-winapi-fork"
    }
    dependencies {
        miette "2.0.0" dev=true
    }
}

$ cat example.kdl | kq "package name => val()"
["foo"]

$ cat example.kdl | kq "dependencies[platform] => platform"
["windows"]

$ cat example.kdl | kq "dependencies > [] => (name(), val(), path)"
[("winapi", "1.0.0", "./crates/my-winapi-fork"), ("miette", "2.0.0", None)]

$ cat example.kdl | kq "dependencies > [] => (name(), values(), props())"
[("winapi", ["1.0.0"], {"platform": "windows"}), ("miette", ["2.0.0"], {"dev": true})]
@jihchi jihchi added the enhancement New feature or request label Oct 19, 2021
@zkat
Copy link

zkat commented Oct 29, 2021

FYI the map operator is going away completely with the next KQL spec, but you might want to come up with something that replaces it?

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

No branches or pull requests

2 participants