-
Notifications
You must be signed in to change notification settings - Fork 330
cmd/cue: add --outfile flag to get go
#4118
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
base: master
Are you sure you want to change the base?
Conversation
56697cf
to
3a72ca5
Compare
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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".
3a72ca5
to
2ffd695
Compare
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]>
2ffd695
to
a7ac603
Compare
Now with added test 😄 |
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