Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

cue export --output=list for ldjson format #280

Closed
mikelnrd opened this issue Feb 8, 2020 · 4 comments
Closed

cue export --output=list for ldjson format #280

mikelnrd opened this issue Feb 8, 2020 · 4 comments
Labels
FeatureRequest New feature or request roadmap/cli Specific tag for roadmap issue #337
Milestone

Comments

@mikelnrd
Copy link

mikelnrd commented Feb 8, 2020

Hi.

I'm experimenting with using cue to import and export ldjson formatted data (basically a list of json structs that are each placed on a single line, separated by a new line character).

I'm able to import this format successfully using the --list option:

cue import --list file.json (after renaming my file.ldjson to file.json)

The feature request: as --list is available as an import option, could something similar be supported as an export option as well?

eg:
cue export --out=list . (or something similar, like --out=ldjson perhaps)

Additionally, perhaps support could be added for the .ldjson extension:
cue import file.ldjson

Loving cue so far. Thanks for your time!

@mikelnrd mikelnrd added the FeatureRequest New feature or request label Feb 8, 2020
@mpvl mpvl added the roadmap/cli Specific tag for roadmap issue #337 label Feb 8, 2020
@mpvl mpvl added this to the v0.0.16 - cli boost milestone Feb 8, 2020
@mpvl
Copy link
Contributor

mpvl commented Feb 12, 2020

So IIUC, --list takes a stream and interprets it as a single list value. So the idea is that if the output of CUE is a list, the --list flag, so some list label would cause a list to be exported as a JSON stream. I think it would be best in that case to generate an error if the generated value is not a list.

We could indeed also go off the file name. This is a bit trickier. The CUE tool allows streaming semantics without interpreting it as a list (e.g. for vet). So it may be strange to interpret .ldjson or .jsonl files as lists by default. Conversely, one should then also not assume list semantics when outputing by default, I think. Actually, I think the file.ldjson is already supported, but one would need to use --list.

@mpvl
Copy link
Contributor

mpvl commented Feb 12, 2020

FYI, if the list tag were to be supported in the current command line syntax, one could indeed write -o list+stream:foo.json to override writing multiple values to a JSON file (invalid JSON), or write -o list:foo.yaml or -o list:foo.jsonl. Maybe list should be the default for jsonl files, but that would mean that the output will be expected to be a list and not a stream. That said, the mechanism already allows different defaults for different operational modes, so it is not out of the question. But it should become too magical.

mpvl added a commit that referenced this issue Feb 17, 2020
The idea is that the build.File type will be added
to the build.Instance type, replacing the current
file specs. It will be populated by the load package.

The command line tool can subsequently use this
package to determine settings on how to interpret
build.File. It is a separate internal package so that
the API can be shared by load and cmd.

Issue #280
Issue #254
Issue #183
Issue #130
Issue #116

Change-Id: I47f2391945113fe664f0ec33b0048be70326edb5
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4946
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
@mpvl
Copy link
Contributor

mpvl commented Mar 7, 2020

I believe this will be addressed by the CLs that will be submitted soon.

mpvl added a commit that referenced this issue Mar 7, 2020
Issue #280

Change-Id: I36de4b3ec70b802ecfe6264015954930dc4bdc16
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5243
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
@mpvl mpvl closed this as completed in 2beaa9c Mar 10, 2020
@myitcv myitcv modified the milestones: v0.0.16 - cli boost, v0.1.0 Apr 9, 2020
@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#280.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest New feature or request roadmap/cli Specific tag for roadmap issue #337
Projects
None yet
Development

No branches or pull requests

4 participants