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

docs/howto: export specific elements in a top-level list #195

Open
jpluscplusm opened this issue Feb 5, 2025 · 2 comments
Open

docs/howto: export specific elements in a top-level list #195

jpluscplusm opened this issue Feb 5, 2025 · 2 comments
Assignees
Labels
howto For content that in the "howto" diataxis quadrant

Comments

@jpluscplusm
Copy link
Collaborator

jpluscplusm commented Feb 5, 2025

We have the pages https://cuelang.org/docs/howto/export-fields-whose-names-are-not-valid-identifiers/ and https://cuelang.org/docs/howto/refer-to-fields-whose-names-are-not-valid-identifiers/, but they don't explicitly mention how the elements of a top-level list can be accessed.

Show an example like this on a separate page, but where

exec cue export list.json -l input: -e 'input[1]'
-- list.json --
[ 1, "2", 3 ]

This page will exist to demonstrate the -e required. No matching page should be needed to handle the case where the reference is required inside CUE code, as that follows directly from this example and the pages mentioned above.

@jpluscplusm jpluscplusm added the howto For content that in the "howto" diataxis quadrant label Feb 5, 2025
@myitcv
Copy link
Member

myitcv commented Feb 5, 2025

Is there a conversation somewhere that motivated this?

@jpluscplusm
Copy link
Collaborator Author

Is there a conversation somewhere that motivated this?

No. I needed to parse some JSON output when building cuelang.org, and realised we don't cover this issue's precise use case on the site.

My specific use case
$ ip -json r g 8.8.8.8 
[{"dst":"8.8.8.8","gateway":"192.168.0.1","dev":"eth0","prefsrc":"192.168.0.200","flags":[],"uid":1100,"cache":[]}]
$ IP=$(ip -json r g 8.8.8.8 | cue export json: - --path input: --expression 'input[0].prefsrc' --out text)
$ ./scripts/serve.bash --update --hugo=--bind=0.0.0.0 --hugo=--baseURL=http://$IP:1313
...

@jpluscplusm jpluscplusm moved this from Backlog to Planned in Docs and Content Roadmap Feb 14, 2025
@jpluscplusm jpluscplusm changed the title docs/howto: reference elements inside a top-level list docs/howto: export specific elements in a top-level list Feb 18, 2025
@jpluscplusm jpluscplusm self-assigned this Feb 18, 2025
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Feb 18, 2025
This adds a guide that demonstrates using the "cue export" command to
place a list data file at an addressable location with "-l", and then
using "-e" with integer list indexing to access a specific element.

Closes cue-lang/docs-and-content#195.

Preview-Path: /docs/howto/export-element-top-level-list/
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: Idb75479a03e8c1798d39558f937f8bd01d3d60fb
Dispatch-Trailer: {"type":"trybot","CL":1208967,"patchset":1,"ref":"refs/changes/67/1208967/1","targetBranch":"master"}
@jpluscplusm jpluscplusm moved this from Planned to In progress in Docs and Content Roadmap Feb 18, 2025
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Feb 19, 2025
This adds a guide that demonstrates using the "cue export" command to
place a list data file at an addressable location with "-l", and then
using "-e" with an integer list index to access a specific element.

Closes cue-lang/docs-and-content#195.

Preview-Path: /docs/howto/export-top-level-list-element/
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: Idb75479a03e8c1798d39558f937f8bd01d3d60fb
Dispatch-Trailer: {"type":"trybot","CL":1208967,"patchset":2,"ref":"refs/changes/67/1208967/2","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Feb 24, 2025
This adds a guide that demonstrates using the "cue export" command to
place a list data file at an addressable location with "-l", and then
using "-e" with an integer list index to access a specific element.

Closes cue-lang/docs-and-content#195.

Preview-Path: /docs/howto/export-top-level-list-element/
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: Idb75479a03e8c1798d39558f937f8bd01d3d60fb
Dispatch-Trailer: {"type":"trybot","CL":1208967,"patchset":3,"ref":"refs/changes/67/1208967/3","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Feb 24, 2025
This adds a guide that demonstrates using the "cue export" command to
place a list data file at an addressable location with "-l", and then
using "-e" with an integer list index to access a specific element.

Closes cue-lang/docs-and-content#195.

Preview-Path: /docs/howto/export-top-level-list-element/
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: Idb75479a03e8c1798d39558f937f8bd01d3d60fb
Dispatch-Trailer: {"type":"trybot","CL":1208967,"patchset":4,"ref":"refs/changes/67/1208967/4","targetBranch":"master"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
howto For content that in the "howto" diataxis quadrant
Projects
Status: In progress
Development

No branches or pull requests

2 participants