diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index ba1d897ad27..2e3c8528b6e 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -435,6 +435,7 @@ Some common cargo commands are (see all commands with --list): new Create a new cargo package init Create a new cargo package in an existing directory add Add dependencies to a manifest file + remove Remove dependencies from a manifest file run, r Run a binary or example of the local package test, t Run the tests bench Run the benchmarks diff --git a/src/doc/man/cargo-add.md b/src/doc/man/cargo-add.md index 10c350089c9..dfca66978cd 100644 --- a/src/doc/man/cargo-add.md +++ b/src/doc/man/cargo-add.md @@ -159,4 +159,4 @@ which enables all specified features. cargo add serde serde_json -F serde/derive ## SEE ALSO -{{man "cargo" 1}} +{{man "cargo" 1}}, {{man "cargo-remove" 1}} diff --git a/src/doc/man/cargo-remove.md b/src/doc/man/cargo-remove.md new file mode 100644 index 00000000000..b0150c1414e --- /dev/null +++ b/src/doc/man/cargo-remove.md @@ -0,0 +1,92 @@ +# cargo-remove(1) +{{*set actionverb="Remove"}} +{{*set nouns="removes"}} + +## NAME + +cargo-remove - Remove dependencies from a Cargo.toml manifest file + +## SYNOPSIS + +`cargo remove` [_options_] _dependency_... + +## DESCRIPTION + +Remove one or more dependencies from a `Cargo.toml` manifest. + +## OPTIONS + +### Section options + +{{#options}} + +{{#option "`--dev`" }} +Remove as a [development dependency](../reference/specifying-dependencies.html#development-dependencies). +{{/option}} + +{{#option "`--build`" }} +Remove as a [build dependency](../reference/specifying-dependencies.html#build-dependencies). +{{/option}} + +{{#option "`--target` _target_" }} +Remove as a dependency to the [given target platform](../reference/specifying-dependencies.html#platform-specific-dependencies). +{{/option}} + +{{/options}} + +### Miscellaneous Options + +{{#options}} + +{{#option "`--dry-run`" }} +Don't actually write to the manifest. +{{/option}} + +{{/options}} + +### Display Options + +{{#options}} +{{> options-display }} +{{/options}} + +### Manifest Options + +{{#options}} +{{> options-manifest-path }} + +{{> options-locked }} +{{/options}} + +### Package Selection + +{{#options}} + +{{#option "`-p` _spec_..." "`--package` _spec_..." }} +Package to remove from. +{{/option}} + +{{/options}} + +{{> section-options-common }} + +{{> section-environment }} + +{{> section-exit-status }} + +## EXAMPLES + +1. Remove `regex` as a dependency + + cargo remove regex + +2. Remove `trybuild` as a dev-dependency + + cargo remove --dev trybuild + +3. Remove `nom` from the `x86_64-pc-windows-gnu` dependencies table + + cargo remove --target x86_64-pc-windows-gnu nom + +## SEE ALSO +{{man "cargo" 1}}, {{man "cargo-add" 1}} diff --git a/src/doc/man/generated_txt/cargo-add.txt b/src/doc/man/generated_txt/cargo-add.txt index 91c47416bdb..7cc7a571257 100644 --- a/src/doc/man/generated_txt/cargo-add.txt +++ b/src/doc/man/generated_txt/cargo-add.txt @@ -188,5 +188,5 @@ EXAMPLES cargo add serde serde_json -F serde/derive SEE ALSO - cargo(1) + cargo(1), cargo-remove(1) diff --git a/src/doc/man/generated_txt/cargo-remove.txt b/src/doc/man/generated_txt/cargo-remove.txt new file mode 100644 index 00000000000..c11992e7f7c --- /dev/null +++ b/src/doc/man/generated_txt/cargo-remove.txt @@ -0,0 +1,138 @@ +CARGO-REMOVE(1) + +NAME + cargo-remove - Remove dependencies from a Cargo.toml manifest file + +SYNOPSIS + cargo remove [options] dependency... + +DESCRIPTION + Remove one or more dependencies from a Cargo.toml manifest. + +OPTIONS + Section options + --dev + Remove as a development dependency + . + + --build + Remove as a build dependency + . + + --target target + Remove as a dependency to the given target platform + . + + Miscellaneous Options + --dry-run + Don't actually write to the manifest. + + Display Options + -v, --verbose + Use verbose output. May be specified twice for "very verbose" output + which includes extra output such as dependency warnings and build + script output. May also be specified with the term.verbose config + value . + + -q, --quiet + Do not print cargo log messages. May also be specified with the + term.quiet config value + . + + --color when + Control when colored output is used. Valid values: + + o auto (default): Automatically detect if color support is + available on the terminal. + + o always: Always display colors. + + o never: Never display colors. + + May also be specified with the term.color config value + . + + Manifest Options + --manifest-path path + Path to the Cargo.toml file. By default, Cargo searches for the + Cargo.toml file in the current directory or any parent directory. + + --frozen, --locked + Either of these flags requires that the Cargo.lock file is + up-to-date. If the lock file is missing, or it needs to be updated, + Cargo will exit with an error. The --frozen flag also prevents Cargo + from attempting to access the network to determine if it is + out-of-date. + + These may be used in environments where you want to assert that the + Cargo.lock file is up-to-date (such as a CI build) or want to avoid + network access. + + --offline + Prevents Cargo from accessing the network for any reason. Without + this flag, Cargo will stop with an error if it needs to access the + network and the network is not available. With this flag, Cargo will + attempt to proceed without the network if possible. + + Beware that this may result in different dependency resolution than + online mode. Cargo will restrict itself to crates that are + downloaded locally, even if there might be a newer version as + indicated in the local copy of the index. See the cargo-fetch(1) + command to download dependencies before going offline. + + May also be specified with the net.offline config value + . + + Package Selection + -p spec..., --package spec... + Package to remove from. + + Common Options + +toolchain + If Cargo has been installed with rustup, and the first argument to + cargo begins with +, it will be interpreted as a rustup toolchain + name (such as +stable or +nightly). See the rustup documentation + for more + information about how toolchain overrides work. + + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. + + -h, --help + Prints help information. + + -Z flag + Unstable (nightly-only) flags to Cargo. Run cargo -Z help for + details. + +ENVIRONMENT + See the reference + + for details on environment variables that Cargo reads. + +EXIT STATUS + o 0: Cargo succeeded. + + o 101: Cargo failed to complete. + +EXAMPLES + 1. Remove regex as a dependency + + cargo remove regex + + 2. Remove trybuild as a dev-dependency + + cargo remove --dev trybuild + + 3. Remove nom from the x86_64-pc-windows-gnu dependencies table + + cargo remove --target x86_64-pc-windows-gnu nom + +SEE ALSO + cargo(1), cargo-add(1) + diff --git a/src/doc/src/SUMMARY.md b/src/doc/src/SUMMARY.md index 453d1121da8..b12dd95cd4e 100644 --- a/src/doc/src/SUMMARY.md +++ b/src/doc/src/SUMMARY.md @@ -66,6 +66,7 @@ * [cargo locate-project](commands/cargo-locate-project.md) * [cargo metadata](commands/cargo-metadata.md) * [cargo pkgid](commands/cargo-pkgid.md) + * [cargo remove](commands/cargo-remove.md) * [cargo tree](commands/cargo-tree.md) * [cargo update](commands/cargo-update.md) * [cargo vendor](commands/cargo-vendor.md) diff --git a/src/doc/src/commands/cargo-add.md b/src/doc/src/commands/cargo-add.md index a397959816e..ea34d80e548 100644 --- a/src/doc/src/commands/cargo-add.md +++ b/src/doc/src/commands/cargo-add.md @@ -231,4 +231,4 @@ details on environment variables that Cargo reads. cargo add serde serde_json -F serde/derive ## SEE ALSO -[cargo(1)](cargo.html) +[cargo(1)](cargo.html), [cargo-remove(1)](cargo-remove.html) diff --git a/src/doc/src/commands/cargo-remove.md b/src/doc/src/commands/cargo-remove.md new file mode 100644 index 00000000000..0a0024f5e83 --- /dev/null +++ b/src/doc/src/commands/cargo-remove.md @@ -0,0 +1,182 @@ +# cargo-remove(1) + + + +## NAME + +cargo-remove - Remove dependencies from a Cargo.toml manifest file + +## SYNOPSIS + +`cargo remove` [_options_] _dependency_... + +## DESCRIPTION + +Remove one or more dependencies from a `Cargo.toml` manifest. + +## OPTIONS + +### Section options + +
+ +
--dev
+
Remove as a development dependency.
+ + +
--build
+
Remove as a build dependency.
+ + +
--target target
+
Remove as a dependency to the given target platform.
+ + +
+ +### Miscellaneous Options + +
+ +
--dry-run
+
Don't actually write to the manifest.
+ + +
+ +### Display Options + +
+
-v
+
--verbose
+
Use verbose output. May be specified twice for "very verbose" output which +includes extra output such as dependency warnings and build script output. +May also be specified with the term.verbose +config value.
+ + +
-q
+
--quiet
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
+ + +
--color when
+
Control when colored output is used. Valid values:

+
    +
  • auto (default): Automatically detect if color support is available on the +terminal.
  • +
  • always: Always display colors.
  • +
  • never: Never display colors.
  • +
+

May also be specified with the term.color +config value.

+ + +
+ +### Manifest Options + +
+
--manifest-path path
+
Path to the Cargo.toml file. By default, Cargo searches for the +Cargo.toml file in the current directory or any parent directory.
+ + + +
--frozen
+
--locked
+
Either of these flags requires that the Cargo.lock file is +up-to-date. If the lock file is missing, or it needs to be updated, Cargo will +exit with an error. The --frozen flag also prevents Cargo from +attempting to access the network to determine if it is out-of-date.

+

These may be used in environments where you want to assert that the +Cargo.lock file is up-to-date (such as a CI build) or want to avoid network +access.

+ + +
--offline
+
Prevents Cargo from accessing the network for any reason. Without this +flag, Cargo will stop with an error if it needs to access the network and +the network is not available. With this flag, Cargo will attempt to +proceed without the network if possible.

+

Beware that this may result in different dependency resolution than online +mode. Cargo will restrict itself to crates that are downloaded locally, even +if there might be a newer version as indicated in the local copy of the index. +See the cargo-fetch(1) command to download dependencies before going +offline.

+

May also be specified with the net.offline config value.

+ + +
+ +### Package Selection + +
+ +
-p spec...
+
--package spec...
+
Package to remove from.
+ + +
+ +### Common Options + +
+ +
+toolchain
+
If Cargo has been installed with rustup, and the first argument to cargo +begins with +, it will be interpreted as a rustup toolchain name (such +as +stable or +nightly). +See the rustup documentation +for more information about how toolchain overrides work.
+ + +
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
+ + +
-h
+
--help
+
Prints help information.
+ + +
-Z flag
+
Unstable (nightly-only) flags to Cargo. Run cargo -Z help for details.
+ + +
+ + +## ENVIRONMENT + +See [the reference](../reference/environment-variables.html) for +details on environment variables that Cargo reads. + + +## EXIT STATUS + +* `0`: Cargo succeeded. +* `101`: Cargo failed to complete. + + +## EXAMPLES + +1. Remove `regex` as a dependency + + cargo remove regex + +2. Remove `trybuild` as a dev-dependency + + cargo remove --dev trybuild + +3. Remove `nom` from the `x86_64-pc-windows-gnu` dependencies table + + cargo remove --target x86_64-pc-windows-gnu nom + +## SEE ALSO +[cargo(1)](cargo.html), [cargo-add(1)](cargo-add.html) diff --git a/src/doc/src/commands/manifest-commands.md b/src/doc/src/commands/manifest-commands.md index 2f4017a71ca..98a82d8aa0b 100644 --- a/src/doc/src/commands/manifest-commands.md +++ b/src/doc/src/commands/manifest-commands.md @@ -4,6 +4,7 @@ * [cargo locate-project](cargo-locate-project.md) * [cargo metadata](cargo-metadata.md) * [cargo pkgid](cargo-pkgid.md) +* [cargo remove](cargo-remove.md) * [cargo tree](cargo-tree.md) * [cargo update](cargo-update.md) * [cargo vendor](cargo-vendor.md) diff --git a/src/etc/man/cargo-add.1 b/src/etc/man/cargo-add.1 index dfcb66dc9a1..d81ee4daa74 100644 --- a/src/etc/man/cargo-add.1 +++ b/src/etc/man/cargo-add.1 @@ -261,4 +261,4 @@ cargo add serde serde_json \-F serde/derive .RE .RE .SH "SEE ALSO" -\fBcargo\fR(1) +\fBcargo\fR(1), \fBcargo\-remove\fR(1) diff --git a/src/etc/man/cargo-remove.1 b/src/etc/man/cargo-remove.1 new file mode 100644 index 00000000000..231af39d081 --- /dev/null +++ b/src/etc/man/cargo-remove.1 @@ -0,0 +1,189 @@ +'\" t +.TH "CARGO\-REMOVE" "1" +.nh +.ad l +.ss \n[.ss] 0 +.SH "NAME" +cargo\-remove \- Remove dependencies from a Cargo.toml manifest file +.SH "SYNOPSIS" +\fBcargo remove\fR [\fIoptions\fR] \fIdependency\fR\&... +.SH "DESCRIPTION" +Remove one or more dependencies from a \fBCargo.toml\fR manifest. +.SH "OPTIONS" +.SS "Section options" +.sp +\fB\-\-dev\fR +.RS 4 +Remove as a \fIdevelopment dependency\fR \&. +.RE +.sp +\fB\-\-build\fR +.RS 4 +Remove as a \fIbuild dependency\fR \&. +.RE +.sp +\fB\-\-target\fR \fItarget\fR +.RS 4 +Remove as a dependency to the \fIgiven target platform\fR \&. +.RE +.SS "Miscellaneous Options" +.sp +\fB\-\-dry\-run\fR +.RS 4 +Don't actually write to the manifest. +.RE +.SS "Display Options" +.sp +\fB\-v\fR, +\fB\-\-verbose\fR +.RS 4 +Use verbose output. May be specified twice for "very verbose" output which +includes extra output such as dependency warnings and build script output. +May also be specified with the \fBterm.verbose\fR +\fIconfig value\fR \&. +.RE +.sp +\fB\-q\fR, +\fB\-\-quiet\fR +.RS 4 +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. +.RE +.sp +\fB\-\-color\fR \fIwhen\fR +.RS 4 +Control when colored output is used. Valid values: +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBauto\fR (default): Automatically detect if color support is available on the +terminal. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBalways\fR: Always display colors. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBnever\fR: Never display colors. +.RE +.sp +May also be specified with the \fBterm.color\fR +\fIconfig value\fR \&. +.RE +.SS "Manifest Options" +.sp +\fB\-\-manifest\-path\fR \fIpath\fR +.RS 4 +Path to the \fBCargo.toml\fR file. By default, Cargo searches for the +\fBCargo.toml\fR file in the current directory or any parent directory. +.RE +.sp +\fB\-\-frozen\fR, +\fB\-\-locked\fR +.RS 4 +Either of these flags requires that the \fBCargo.lock\fR file is +up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will +exit with an error. The \fB\-\-frozen\fR flag also prevents Cargo from +attempting to access the network to determine if it is out\-of\-date. +.sp +These may be used in environments where you want to assert that the +\fBCargo.lock\fR file is up\-to\-date (such as a CI build) or want to avoid network +access. +.RE +.sp +\fB\-\-offline\fR +.RS 4 +Prevents Cargo from accessing the network for any reason. Without this +flag, Cargo will stop with an error if it needs to access the network and +the network is not available. With this flag, Cargo will attempt to +proceed without the network if possible. +.sp +Beware that this may result in different dependency resolution than online +mode. Cargo will restrict itself to crates that are downloaded locally, even +if there might be a newer version as indicated in the local copy of the index. +See the \fBcargo\-fetch\fR(1) command to download dependencies before going +offline. +.sp +May also be specified with the \fBnet.offline\fR \fIconfig value\fR \&. +.RE +.SS "Package Selection" +.sp +\fB\-p\fR \fIspec\fR\&..., +\fB\-\-package\fR \fIspec\fR\&... +.RS 4 +Package to remove from. +.RE +.SS "Common Options" +.sp +\fB+\fR\fItoolchain\fR +.RS 4 +If Cargo has been installed with rustup, and the first argument to \fBcargo\fR +begins with \fB+\fR, it will be interpreted as a rustup toolchain name (such +as \fB+stable\fR or \fB+nightly\fR). +See the \fIrustup documentation\fR +for more information about how toolchain overrides work. +.RE +.sp +\fB\-\-config\fR \fIKEY=VALUE\fR or \fIPATH\fR +.RS 4 +Overrides a Cargo configuration value. The argument should be in TOML syntax of \fBKEY=VALUE\fR, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the \fIcommand\-line overrides section\fR for more information. +.RE +.sp +\fB\-h\fR, +\fB\-\-help\fR +.RS 4 +Prints help information. +.RE +.sp +\fB\-Z\fR \fIflag\fR +.RS 4 +Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fR for details. +.RE +.SH "ENVIRONMENT" +See \fIthe reference\fR for +details on environment variables that Cargo reads. +.SH "EXIT STATUS" +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fB0\fR: Cargo succeeded. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fB101\fR: Cargo failed to complete. +.RE +.SH "EXAMPLES" +.sp +.RS 4 +\h'-04' 1.\h'+01'Remove \fBregex\fR as a dependency +.sp +.RS 4 +.nf +cargo remove regex +.fi +.RE +.RE +.sp +.RS 4 +\h'-04' 2.\h'+01'Remove \fBtrybuild\fR as a dev\-dependency +.sp +.RS 4 +.nf +cargo remove \-\-dev trybuild +.fi +.RE +.RE +.sp +.RS 4 +\h'-04' 3.\h'+01'Remove \fBnom\fR from the \fBx86_64\-pc\-windows\-gnu\fR dependencies table +.sp +.RS 4 +.nf +cargo remove \-\-target x86_64\-pc\-windows\-gnu nom +.fi +.RE +.RE +.SH "SEE ALSO" +\fBcargo\fR(1), \fBcargo\-add\fR(1)