1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-07-10 16:20:15 +02:00

Provide shorter Cargo aliases for xtool subcommands (#2804)

This change deprecates the use of `cargo xtask <tool>` in favor of
dedicated aliases for each tool.

| Proposed | Current |
|----------|---------|
| `cargo install-tools` |  `cargo xtask install-tools` |
| `cargo web-tests` |  `cargo xtask web-tests` |
| `cargo rust-tests` |  `cargo xtask rust-tests` |
| `cargo serve` |  `cargo xtask serve` |
| `cargo build-book` |  `cargo xtask build` |

_Note_: Because `build` is a pre-existing Cargo sub-command, I've
proposed `cargo build-book` as a strawman.


Fixes #2803
This commit is contained in:
Tim McNamara
2025-07-06 05:44:47 +12:00
committed by GitHub
parent 010b443615
commit 7c23d3bcf8
2 changed files with 28 additions and 9 deletions

View File

@ -1,7 +1,12 @@
[alias] [alias]
# We use this alias for task automation in the project. # WARNING: Using the `xtask` alias is deprecated and will be unsupported in a
# See README in xtask directory. # future version of Cargo. See https://github.com/rust-lang/cargo/issues/10049.
xtask = "run --package xtask --" xtask = "run --package xtask --"
install-tools = "run --package xtask -- install-tools"
web-tests = "run --package xtask -- web-tests"
rust-tests = "run --package xtask -- rust-tests"
serve = "run --package xtask -- serve"
build-book = "run --package xtask -- build"
[env] [env]
# To provide an anchor to the root of the workspace when working with paths. # To provide an anchor to the root of the workspace when working with paths.

View File

@ -76,16 +76,30 @@ cargo xtask install-tools
Here is a summary of the various commands you can run in the project. Here is a summary of the various commands you can run in the project.
| Command | Description | | Command | Description |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cargo xtask install-tools` | Install all the tools the project depends on. | | `cargo install-tools` | Install all the tools the project depends on. |
| `cargo xtask serve` | Start a web server with the course. You'll find the content on http://localhost:3000. | | `cargo serve` | Start a web server with the course. You'll find the content on http://localhost:3000. |
| `cargo xtask rust-tests` | Test the included Rust snippets. | | `cargo rust-tests` | Test the included Rust snippets. |
| `cargo xtask web-tests` | Run the web driver tests in the tests directory. | | `cargo web-tests` | Run the web driver tests in the tests directory. |
| `cargo xtask build` | Create a static version of the course in the `book/` directory. Note that you have to separately build and zip exercises and add them to book/html. To build any of the translated versions of the course, run MDBOOK_BOOK__LANGUAGE=xx mdbook build -d book/xx where xx is the ISO 639 language code (e.g. da for the Danish translation). [TRANSLATIONS.md](TRANSLATIONS.md) contains further instructions. | | `cargo build-book` | Create a static version of the course in the `book/` directory. Note that you have to separately build and zip exercises and add them to book/html. To build any of the translated versions of the course, run MDBOOK_BOOK__LANGUAGE=xx mdbook build -d book/xx where xx is the ISO 639 language code (e.g. da for the Danish translation). [TRANSLATIONS.md](TRANSLATIONS.md) contains further instructions. |
> **Note** On Windows, you need to enable symlinks > **Note** On Windows, you need to enable symlinks
> (`git config --global core.symlinks true`) and Developer Mode. > (`git config --global core.symlinks true`) and Developer Mode.
> **Note** Previous versions this README recommended that you use
> `cargo xtool <tool>`, i.e. `cargo xtool install-tools`. This causes issues
> with pre-existing installations of `cargo-xtool` and is now deprecated.
>
> The new syntax is almost a 1:1 mapping, although `cargo xtool build` has
> become `cargo build-book` to avoid conflicting with the built-in Cargo
> subcommand.
>
> - `cargo xtool build` -> `cargo build-book`
> - `cargo xtool install-tools` -> `cargo install-tools`
> - `cargo xtool serve` -> `cargo serve`
> - `cargo xtool run-tests` -> `cargo run-tests`
> - `cargo xtool web-tests` -> `cargo web-tests`
## Contributing ## Contributing
We would like to receive your contributions. Please see We would like to receive your contributions. Please see