-
Notifications
You must be signed in to change notification settings - Fork 23
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
How to check whether a given task exists or not? #10
Comments
Potential solutions that come to my mind:
|
I'll bump this. I'd really like to use xtask from cargo-deb, but the current black-box design ("parse whatever args you want however you want") is fundamentally incompatible with cargo-deb. |
Yeah, these are all good questions.... I am personally not familiar with listed use-cases that much, so can't give guidance here. Process wise, @kornelski, can you just draft some design which you think works for this, we'll merge this into the repo and see how it works in practice? We'll need more scrunity before we set it in stone and recommend folks to use it, but having something in the meantime would be better than analysis-paralisis. My straw man proposal is: Add [package.metadata.xtask]
dist = true or like this: [package.metadata.xtask]
dist = "cargo -p xtask run -- --dist my-custom-flag" The benefit here is that the consuming tool knows statically what commands are available, and it's easy enough to add some additional meta later. The drawback is that a human would need to manually sync Cargo.toml and whatever xtask commands they want to publicly expose. |
I'd rather avoid putting shell scripts in Maybe [alias]
xtask = "run --package xtask --"
xtask-dist = "run --whatever --dist" |
@kornelski those are not intended to be shell scripts, those are arguments to And yeah, given that, I really like your idea of using Could you send a PR which documents "API* commands which are recognized by 3rd party tooling and have specific interface? Something along the lines of:
I believe cargo never invokes system's shell. |
yikes, Cargo just does |
Still better than invoking the shell though :-) But yeah, having something like python shelx in Rust would be lovely for such use-cases. |
I'm concerned that the design of xtask as a single all-tasks binary with custom opaque command-line parsing doesn't allow external tools to integrate with the tasks. This limits xtask to UI interaction with humans only, and doesn't allow graceful integration with packagers, CI or editors.
For example, when adding a new project in a CI service, the service could search the repository to decide how to build it, and create a build template automatically. For Cargo projects that's something like
cargo test --all
. But ifxtask
was machine-readable, the CI could also check ifxtask ci
exists, and use it instead of the defaultcargo test
. There's similar story for deployments like Heroku or packaging likecargo-deb
. They could replace Rusty default assumptions with a specific tasks, if they could know that the task is implemented by the xtask binary.However, this is currently not possible, because mere presence of the
xtask
crate is not enough to know thatxtask ci
works. Runningxtask
commands to see if they work is not reliable (e.g.xtask ci
may fail because tests failed, not because the subcommand is not implemented. Conversely,xtask ci
can succeed because a custom command-line parsing library interprets it as some other argument or fails to use appropriate exit code).Running
xtask --help
might work sometimes, but it's not a machine readable output, and in any case running arbitrary code to check what it supports is not so great. Especially when the thing that inspects the repo is not prepared to sandbox arbitrary code (the configuration-detection part of a system is usually separate from the part that runs the configured project sandboxed).The text was updated successfully, but these errors were encountered: