cargo CLI reference
ModularPipelines.Rust provides strongly typed access to the cargo CLI.
Executable prerequisite
This package does not install the cargo executable. Install it separately and ensure cargo is available on PATH.
Follow the executable's official documentation for installation instructions.
Package installation
dotnet add package ModularPipelines.Rust
Resolve the service with context.Tools.Cargo.
Projects using C# 13 or another .NET language can use context.Tools.Get<ModularPipelines.Rust.Services.ICargo>() instead.
Module example
using ModularPipelines;
using ModularPipelines.Rust.Enums;
using ModularPipelines.Rust.Options;
public class RunCommandModule : Module<CommandResult>
{
protected override async Task<CommandResult> ExecuteAsync(
IModuleContext context,
CancellationToken cancellationToken)
{
return await context.Tools.Cargo.CheckAsync(
new CargoCheckOptions()
{
Quiet = true,
},
cancellationToken: cancellationToken);
}
}
Global options
Global options are rendered before the selected subcommand.
| CLI option | Property | Availability | Description |
|---|---|---|---|
--color | Color | All editions | Coloring |
--config | Config | All editions | Override a configuration value |
--frozen | Frozen | All editions | Equivalent to specifying both --locked and --offline |
--locked | Locked | All editions | Assert that Cargo.lock will remain unchanged |
--offline | Offline | All editions | Run without accessing the network |
--quiet | Quiet | All editions | Do not print cargo log messages |
--verbose | Verbose | All editions | Use verbose output (-vv very verbose/build.rs output) |
Commands
| CLI command | Options record |
|---|---|
cargo add | CargoAddOptions |
cargo bench | CargoBenchOptions |
cargo build | CargoBuildOptions |
cargo check | CargoCheckOptions |
cargo clean | CargoCleanOptions |
cargo doc | CargoDocOptions |
cargo init | CargoInitOptions |
cargo install | CargoInstallOptions |
cargo new | CargoNewOptions |
cargo publish | CargoPublishOptions |
cargo remove | CargoRemoveOptions |
cargo run | CargoRunOptions |
cargo search | CargoSearchOptions |
cargo test | CargoTestOptions |
cargo uninstall | CargoUninstallOptions |
cargo update | CargoUpdateOptions |