Skip to main content

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 optionPropertyAvailabilityDescription
--colorColorAll editionsColoring
--configConfigAll editionsOverride a configuration value
--frozenFrozenAll editionsEquivalent to specifying both --locked and --offline
--lockedLockedAll editionsAssert that Cargo.lock will remain unchanged
--offlineOfflineAll editionsRun without accessing the network
--quietQuietAll editionsDo not print cargo log messages
--verboseVerboseAll editionsUse verbose output (-vv very verbose/build.rs output)

Commands​

CLI commandOptions record
cargo addCargoAddOptions
cargo benchCargoBenchOptions
cargo buildCargoBuildOptions
cargo checkCargoCheckOptions
cargo cleanCargoCleanOptions
cargo docCargoDocOptions
cargo initCargoInitOptions
cargo installCargoInstallOptions
cargo newCargoNewOptions
cargo publishCargoPublishOptions
cargo removeCargoRemoveOptions
cargo runCargoRunOptions
cargo searchCargoSearchOptions
cargo testCargoTestOptions
cargo uninstallCargoUninstallOptions
cargo updateCargoUpdateOptions