Open rogpeppe opened 2 months ago
@rogpeppe was this done as part of the work for ignoring _test.cue
files?
Here's a testscript that demonstrates the issue:
exec cue cmd test
cmp stdout want-stdout
-- want-stdout --
{"normal":true}
-- cue.mod/module.cue --
module: "cue.example/foo"
language: version: "v0.9.2"
-- foo_tool.cue --
package foo
import (
"tool/cli"
"encoding/json"
"cue.example/foo/bar"
)
command: test: {
print: cli.Print & {
text: json.Marshal(bar)
}
}
-- bar/bar.cue --
package bar
normal: true
-- bar/bar_tool.cue --
package bar
tool: true
As this is a backwards incompatible change, if/when we fix this, we could gate the changed behaviour on the declared language version.
As Roger said in the last comment, this is a potentially breaking change that we want to do carefully in an alpha release, so I've pushed it back slightly to v0.11.0-alpha.1.
*_tool.cue
files are intended to contain commands forcue cmd
- they make sense only when the package is intended to be run as an explicit argument tocue cmd
.However, currently, when
cue cmd
is running, all_tool.cue
files in any dependency are merged into their respective packages regardless of whether those packages are explicitly named on the command line.Originally, the packages in
tool/...
were not available to import in non tools files, so it was necessary to put any tools helper code inside_tool.cue
files too, but that restriction hasn't been the case for a long time now.We propose that
_tool.cue
files should be excluded from all packages except those explicitly mentioned on thecue cmd
command line.