$ command-helper

Rust: cargo and rustup

Projects and dependencies, building and testing, lints and formatting, toolchains and cross-compilation.

Requires Google sign-in

Projects

New binary / library project
cargo new <project> && cargo new --lib <project>-core
Add a dependency (with features)
cargo add <crate> --features full
Update dependencies within semver
cargo update

Build and run

Fast check without building
cargo check
Run (with arguments)
cargo run -- --help
Release build
cargo build --release
Install a CLI from crates.io
cargo install <crate>

Tests and quality

All tests
cargo test
Tests matching a name, with println output
cargo test <test_method> -- --nocapture
Lints, failing on warnings
cargo clippy --all-targets -- -D warnings
Format
cargo fmt
Check dependencies for known vulnerabilitiesadvanced
cargo install cargo-audit && cargo audit
Who depends on a crateadvanced
cargo tree -i <crate>

rustup

Update the toolchain
rustup update
Pin a toolchain for the projectadvanced
rustup override set 1.85.0
Add a cross-compilation targetadvanced
rustup target add aarch64-unknown-linux-gnu && cargo build --release --target aarch64-unknown-linux-gnu