Skip to content

Conversation

fionera
Copy link

@fionera fionera commented Oct 6, 2025

This introduces a way to write generated cue schemas to a given file or stdout. It joins all declarations into one giant file and preserves all package comments.

Closes #4108

@fionera fionera requested a review from cueckoo as a code owner October 6, 2025 22:49
@fionera fionera force-pushed the feature/get-go-one-shot branch from 56697cf to 3a72ca5 Compare October 6, 2025 22:50
Copy link
Member

@mvdan mvdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

largely SGTM but needs a test. for example, copy get_go_vendor.txtar into get_go_outfile.txtar and adapt as you see fit. ideally we test the multi-file package scenario as well.


pkg := &cueast.Package{Name: e.ident(pName, false)}
addDoc(f.Doc, pkg)
if flagOutFile.IsSet(e.cmd) && i != len(p.Syntax)-1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty funky. the logic is not particularly easy to follow. can we add more comments? perhaps one jsut above the main for loop, explaining how the regular and "outfile" modes differ.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. The logic is kinda ugly but I stared the last two hours on this and didn't found a nice way to structure this that wouldn't copy all the logic

Copy link
Member

@mvdan mvdan Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing obvious comes to mind, the code as is is fine - it just needs a bit of a summary, like "in outfile mode, we accumulate into a single cue file and we write when we're done with the last go file".

@fionera fionera force-pushed the feature/get-go-one-shot branch from 3a72ca5 to 2ffd695 Compare October 7, 2025 00:20
@fionera fionera requested a review from mvdan October 7, 2025 00:20
@fionera
Copy link
Author

fionera commented Oct 7, 2025

Ah forgot the test, ignore the request for review. Sorry ^^'

This introduces a way to write generated cue schemas to a given file or
stdout. It joins all declarations into one giant file and preserves all
package comments.

Signed-off-by: Tim Windelschmidt <[email protected]>
@fionera fionera force-pushed the feature/get-go-one-shot branch from 2ffd695 to a7ac603 Compare October 7, 2025 14:26
@fionera
Copy link
Author

fionera commented Oct 7, 2025

Now with added test 😄

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

Successfully merging this pull request may close these issues.

cmd/cue: Add --skip-imports, --keep-empty, --out to get go
2 participants