Skip to content

Commit 7c23d3b

Browse files
authored
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
1 parent 010b443 commit 7c23d3b

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

.cargo/config.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
[alias]
2-
# We use this alias for task automation in the project.
3-
# See README in xtask directory.
2+
# WARNING: Using the `xtask` alias is deprecated and will be unsupported in a
3+
# future version of Cargo. See https://github.com/rust-lang/cargo/issues/10049.
44
xtask = "run --package xtask --"
5+
install-tools = "run --package xtask -- install-tools"
6+
web-tests = "run --package xtask -- web-tests"
7+
rust-tests = "run --package xtask -- rust-tests"
8+
serve = "run --package xtask -- serve"
9+
build-book = "run --package xtask -- build"
510

611
[env]
712
# To provide an anchor to the root of the workspace when working with paths.

README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,31 @@ cargo xtask install-tools
7575

7676
Here is a summary of the various commands you can run in the project.
7777

78-
| Command | Description |
79-
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80-
| `cargo xtask install-tools` | Install all the tools the project depends on. |
81-
| `cargo xtask serve` | Start a web server with the course. You'll find the content on http://localhost:3000. |
82-
| `cargo xtask rust-tests` | Test the included Rust snippets. |
83-
| `cargo xtask web-tests` | Run the web driver tests in the tests directory. |
84-
| `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. |
78+
| Command | Description |
79+
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80+
| `cargo install-tools` | Install all the tools the project depends on. |
81+
| `cargo serve` | Start a web server with the course. You'll find the content on http://localhost:3000. |
82+
| `cargo rust-tests` | Test the included Rust snippets. |
83+
| `cargo web-tests` | Run the web driver tests in the tests directory. |
84+
| `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. |
8585

8686
> **Note** On Windows, you need to enable symlinks
8787
> (`git config --global core.symlinks true`) and Developer Mode.
8888
89+
> **Note** Previous versions this README recommended that you use
90+
> `cargo xtool <tool>`, i.e. `cargo xtool install-tools`. This causes issues
91+
> with pre-existing installations of `cargo-xtool` and is now deprecated.
92+
>
93+
> The new syntax is almost a 1:1 mapping, although `cargo xtool build` has
94+
> become `cargo build-book` to avoid conflicting with the built-in Cargo
95+
> subcommand.
96+
>
97+
> - `cargo xtool build` -> `cargo build-book`
98+
> - `cargo xtool install-tools` -> `cargo install-tools`
99+
> - `cargo xtool serve` -> `cargo serve`
100+
> - `cargo xtool run-tests` -> `cargo run-tests`
101+
> - `cargo xtool web-tests` -> `cargo web-tests`
102+
89103
## Contributing
90104

91105
We would like to receive your contributions. Please see

0 commit comments

Comments
 (0)