-
Notifications
You must be signed in to change notification settings - Fork 302
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
cmd/cue: root keys with dashes in their name cannot be extracted with cue eval -e #358
Comments
Original reply by @verdverm in cuelang/cue#358 (comment) This is some tracing I have done to follow the code path:
This is where we go to the parser with the flag, and likely return the wrong kind of expression. This is where to put a break point and check input/output with Delve. The following may be related:
These may be a bit out of order, but the main points are there. My best guess is that something in parsing the expressions is broken down this path. I have also tried the input Really need to get into Delve more by default... |
Original reply by @verdverm in cuelang/cue#358 (comment) TL;DR At https://github.com/cuelang/cue/blob/master/cmd/cue/cmd/common.go#L472
while
and
|
Original reply by @verdverm in cuelang/cue#358 (comment) Here might be the "root" question... "How does one access top-level keys which require indexing due to the format of the identifier?" https://cuelang.org/docs/tutorials/tour/references/selectors/ In this link, the indexing happens on a struct field. Is there a notation to specify the root / file level equivalent to a in this example? |
Original reply by @mpvl in cuelang/cue#358 (comment) This is not a bug: the dashed key is not a valid identifier, and the Within CUE, the workaround is to use a field alias
As aliases are not visible outside the scope in which they are defined, this is not a solution for There are two possible solutions:
The latter was actually supported at some point, but it seems to be too confusing. It may be a possibility, though. Option 1. has deliberately not been supported, as it is too easy to misuse this feature: it's use will almost always be wrong and it is hardly ever necessary. That said, we could consider supporting a symbol for root that is only available from the command line, such as The use of |
Original reply by @capelio in cuelang/cue#358 (comment) @mpvl From my end-user perspective, the dashed cue is "valid" in so much as we can import the cue file and get to the underlying values with paths like |
For folks searching for relevant issues in the future: this also affects field names containing periods. |
This may be sufficiently different from the headline issue that it's not helpful, but here's how I worked around this issue when trying to use
|
Originally opened by @capelio in cuelang/cue#358
What version of CUE are you using (
cue version
)?I performed a fresh
go get -u cuelang.org/go/cmd/cue
as of the time and date this issue was opened.Does this issue reproduce with the latest release?
I tested with the latest
devel
code as of the date and time this issue was created. I have not tested with any prior official releases.What did you do?
I attempted to extract a root key from a CUE file using
cue eval -e
. The root key has a dash in its name, which appears to be causing problems. Here is the repo case:Create a new
data.cue
file with the following contents:Run
cue eval data.cue -e foo
, which returnsone: 1
as expected.However, the following attempts to get the
foo-bar
key fail.What did you expect to see?
I expected to see
two: 2
returned.What did you see instead?
See above errors.
The text was updated successfully, but these errors were encountered: