Extending cargo is surprisingly easy. To do this, perform the following steps:
- Create a new Rust binary application project with the following command: cargo new cargo-hello.
- Change into the directory with cd cargo-hello and build it using cargo build.
- Add the target/debug folder of the current project that is located at your PATH variable. On Linux and Mac (using bash), it's simply as follows:
export PATH=$PATH:/path/to/cargo-hello/target/debug
On Windows, you can use PowerShell to achieve the same goal with this code script:
$env:Path += ";C:/path/to/cargo-hello/target/debug"
- Within the same window, you should now be able to run cargo-hello (cargo-hello.exe on Windows) from any directory on the computer.
- Additionally, ...