-
Notifications
You must be signed in to change notification settings - Fork 287
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
proposal: cmd/cue: rename 'cue cmd' to 'cue run' or 'cuerun' #1325
Comments
Should cue cmd allow importing and unifying non-CUE files like other commands that adhere to the interface described in cue flags? |
@seh such non-CUE files cannot, by definition, apply to the command specification, so presumably you are referring to data that is consumed as part of the command execution? If so, yes, that is in scope. At the moment, the "merge" of command and package is rather confusing to both implement and understand. I've added a note above about (forgot to do so earlier) for clearer designation of the command specification vs the package on which the command operates. But if you have specific examples to help motivate the design that would be very useful, thanks. |
I had tried to use cue cmd to write a filter, where I wanted to supply several JSON file paths, have CUE import them and unify them against a definition (using the Perhaps I could have written the "import JSON and unify it with a definition" part in CUE myself, for lack of being able to use the |
Note that this will not be a simple rename, but rather, we would use this opportunity to clean things up. One issue currently is that the files that define the command and the files on which the command is run are the same. This is not always desirable. I could envision having these separated, allowing the aforementioned flags for some of them. It seems that your specific use case can be quite useful to work out the specifics for this, so it may be useful to get some more detail here. |
Not sure if this belongs in this same issue, but I would love to be able to visualize a cue workflow. Even a transformation from the (tool/flow) DAG into graphviz dot or something would be handy. There is this example that dumps the current state into a mermaid graph: Lines 230 to 240 in fa141c2
But that's not easily reusable and you'd probably have to run it after the flow is done since tasks can be dynamically generated based on the output of another. |
I had some further thoughts on workflows/pipelines. Since with Makefiles
This is how I use make2graph on my local (mac) machine:
|
My thoughts based on what I want to see: I would like command definitions to be simply data. Unless Looking forward, we can imagine that a single CUE package may hold definitions that multiple separate tools would want to read, not only There are nuances in how that would work but the general goal would be for Semi-related note.
We can see from above that we can avoid name collisions with a domain namespace which opens up a decentralized way for developers to define resources. This allows definitions to coexist based on a standard. A resource model is a discussion in itself but I thought this would be a good way to demonstrate a way for |
Related to a redesign of
The top-level cue command also has to do quite a bit of heavy lifting to figure out whether the first argument might be a custom command or not. Sometimes this causes surprising slow-downs, like #2161. And in general, it makes cue's top-level command quite complex in its implementation, as it has quite a bit of intricate logic to treat "unknown command" as a fall-back to loading custom commands. I've also been bitten by this when typoing standard top-level commands. For example:
I think this command should fail immediately with a better error message, and not even try to run a custom command. Otherwise, beyond the confusing error messages and time spent to load the current CUE package, whenever I run a top-level command there's the slight worry that maybe I'm running a custom command without realizing it. I would personally not support shortcuts or aliases for running commands or tasks defined in CUE. Typing |
Running cue export on the github package is a good way of tracking down issues with workflow declarations that are otherwise impossible to find when running cue cmd to regenerate the yml outputs. These bugs are known about and effectively captured by #1325. Right now, because we declare the field named base to be the package value of the imported base package, such an export fails because there are many fields of that package value that cannot be exported because they are not concrete. Fix that by making the field hidden, which allows the cue export trick to work again. Signed-off-by: Paul Jolly <paul@myitcv.io> Change-Id: Icd9df2beab51ff2ae34ac3eb641d6c739b01e2ce
Running cue export on the github package is a good way of tracking down issues with workflow declarations that are otherwise impossible to find when running cue cmd to regenerate the yml outputs. These bugs are known about and effectively captured by #1325. Right now, because we declare the field named base to be the package value of the imported base package, such an export fails because there are many fields of that package value that cannot be exported because they are not concrete. Fix that by making the field hidden, which allows the cue export trick to work again. Signed-off-by: Paul Jolly <paul@myitcv.io> Change-Id: Icd9df2beab51ff2ae34ac3eb641d6c739b01e2ce Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/551826 Unity-Result: CUEcueckoo <cueckoo@cuelang.org> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
I just raised #2324 as an aide memoire so that I don't forget about it. It's related to this issue, but only insofar as |
Adding details of a report from Slack of a clear confusion that arises when calling a command with a pattern argument. What did you do?
What did you expect to see?There are any number of potential expectations (hence the plan to address this with
Part of the challenge is that it's not clear which Noting #1138 in the context of the expansion of What did you see instead?
Per the expectation above, hard to know whether this is "right" or "wrong". |
Not sure if this is helpful but (and this might be a bit of abuse) but I run a command So my expectation would be if I run with Now all files in my repo are part of one mega package (again probably an abuse) but my expectation would be to run against the one package it finds (if it finds only one), OR fail and expect you to provide a package that you would like the package to run against. I think running a command implicitly multiple times, once per package would not be intuitive. I also think setting the working directory to the package root would only make sense if you were to run multiple instances of the command once per package. Generally speaking when you run commands on the command line the perspective of what takes place is the cwd of where the command was run, not what files the command is executing against. You can always add extra explicit arguments on top of the default to add things like parallel per package instances of running a command, or you know, write a bash command to do the same thing (unix style) Those are my opinions, and expectations if that is helpful. |
This is helpful, there is a broader conversation about the UX/DX of the You can actually build your own I'd be very curious to know if |
So I don't have any problems with |
Thanks to Paul Jolly for writing the testscript in a comment on #1325. It is added here with some minor tweaks: adding more comments, and reflecting the current behavior with the last command failing. Without such a test, it's hard to notice when we might break users who rely on the existing behavior, intentionally or not. Signed-off-by: Daniel Martí <mvdan@mvdan.cc> Change-Id: I82d0229d085e8d63fc3e170e2c92f66434159117
Thanks to Paul Jolly for writing the testscript in a comment on #1325. It is added here with some minor tweaks: adding more comments, and reflecting the current behavior with the last command failing. Without such a test, it's hard to notice when we might break users who rely on the existing behavior, intentionally or not. Signed-off-by: Daniel Martí <mvdan@mvdan.cc> Change-Id: I82d0229d085e8d63fc3e170e2c92f66434159117 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193717 Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Reviewed-by: Paul Jolly <paul@myitcv.io>
Another sharp edge: |
One thing that might be nice is if there were a way to control flow for a whole group of tasks at once. For example, setting the |
Whilst this wouldn't necessarily be done via a
This is possible today using pattern constraints:
I'm not clear we need/want another mechanism for expressing this. |
Using |
Some more ideas (edited):
|
The initial text of this issue says:
This is not quite right. The command is derived from any Here's a demonstration of the behaviour of packages mentioned on the command line. Note that there is no package in the current directory:
|
In #337 and various other places we have mooted the idea of moving the logic from
cue cmd
to a different command, withcue run
or another entry point entirelycuerun
(originally an idea from @shykes)Creating this issue as a WIP placeholder for a full proposal for such a move, with rough notes as follows:
Currently[Edit: See this comment] We might want to support this so that running a command from an alternative location within the main module is supported (for example the command could even be defined in a dependency of the main module). This is especially true in the world of modules, where one might want to do that equivalent ofcue cmd
does not have a means by which the user can specify the package (path) from which the command is derived: it is currently.
.go run $pkg
. Indeed we could go one step further and consider something equivalent togo run $pkg@$version
and then the dependency does not even need to exist as a dependency in the main module_tool.cue
to designate the command specification. We kicked around the idea of*_tool
package space, much like Go's*_test
external tests$id
-style fields are used to identify taskscue run
as opposed tocuerun
is that flags can precede therun
incue run
. Whether we require this or not remains to be seen, just noting FYIcue cmd
$after
), so that other tasks can depend on the "exit code" for a task. Control flow could be introduced to handle failure cases, with a default behaviour of failing the entire command if nothing depends on the failure case. See cmd/cue cmd: unable to depend on output of another task #1568.$CWD
of command)[]string
that could be consumed by a tasktool/file.Glob
currently passes the argument through to https://pkg.go.dev/path/filepath#Glob, which unfortunately allows**
as an equivalent to*
, which can be confusing to users and makes it hard to later decide to start supporting "extended globbing" to recurse into subdirectories.@embed
attribute. The arguments to@embed
are designed to follow closely the behaviour ofcmd/cue
with respect to its inputs. This consistency is intentional. However there is now a large gap in capability and convenience when it comes to loading files via workflows. We should therefore introduce a tool-based function (in an existing/new package) that provides the same functionality as@embed
.The text was updated successfully, but these errors were encountered: