cmdxray / commands / cargo

What does cargo do?

the Rust package manager and build tool.

▸ Explain your own cargo command →

cargo examples, explained

$ cargo build --release

  • cargothe Rust package manager and build tool
  • buildcompile the current package
  • --releasebuild with optimizations (the release profile)

$ cargo test --workspace --all-features

  • cargothe Rust package manager and build tool
  • testrun the package's tests
  • --workspacerun the command for every package in the workspace
  • --all-featuresactivate all Cargo features

$ cargo add serde --features derive

  • cargothe Rust package manager and build tool
  • addadd a dependency to Cargo.toml
  • serdean argument passed to the command
  • --featuresspace/comma-separated list of features to activate
  • derivevalue for --features

cargo subcommands

build — compile the current packagerun — build and run a binary targettest — run the package's testscheck — type-check without producing a binaryadd — add a dependency to Cargo.tomlremove — remove a dependency from Cargo.tomlupdate — update dependencies in Cargo.lockpublish — upload the crate to a registry (crates.io)install — build and install a Rust binarynew — create a new cargo packageinit — create a cargo package in an existing directoryclippy — run the Clippy linterfmt — format the code with rustfmtbench — run benchmarks

cargo flags & options

--releasebuild with optimizations (the release profile)
--all-featuresactivate all Cargo features
--no-default-featuresdo not activate the default feature set
--featuresspace/comma-separated list of features to activate
--workspacerun the command for every package in the workspace
--packagerun the command for this package only
--binbuild/run only this binary target
--examplebuild/run this example target
--targetbuild for the given target triple
--lockedrequire an up-to-date Cargo.lock and don't change it
--offlinerun without accessing the network

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.