Skip to content

Commit 36f0b6a

Browse files
committed
Auto merge of #11227 - cassaundra:remove-docs, r=epage
Document `cargo remove` ### What does this PR try to resolve? This PR continues the deferred work of #11099 by adding documentation for the cargo remove subcommand. ### How should we test and review this PR? Ensure that the documentation renders correctly and appropriately covers the feature.
2 parents b592ba4 + 74b29d2 commit 36f0b6a

File tree

10 files changed

+607
-4
lines changed

10 files changed

+607
-4
lines changed

src/bin/cargo/cli.rs

+1
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ Some common cargo commands are (see all commands with --list):
435435
new Create a new cargo package
436436
init Create a new cargo package in an existing directory
437437
add Add dependencies to a manifest file
438+
remove Remove dependencies from a manifest file
438439
run, r Run a binary or example of the local package
439440
test, t Run the tests
440441
bench Run the benchmarks

src/doc/man/cargo-add.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,4 @@ which enables all specified features.
159159
cargo add serde serde_json -F serde/derive
160160

161161
## SEE ALSO
162-
{{man "cargo" 1}}
162+
{{man "cargo" 1}}, {{man "cargo-remove" 1}}

src/doc/man/cargo-remove.md

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# cargo-remove(1)
2+
{{*set actionverb="Remove"}}
3+
{{*set nouns="removes"}}
4+
5+
## NAME
6+
7+
cargo-remove - Remove dependencies from a Cargo.toml manifest file
8+
9+
## SYNOPSIS
10+
11+
`cargo remove` [_options_] _dependency_...
12+
13+
## DESCRIPTION
14+
15+
Remove one or more dependencies from a `Cargo.toml` manifest.
16+
17+
## OPTIONS
18+
19+
### Section options
20+
21+
{{#options}}
22+
23+
{{#option "`--dev`" }}
24+
Remove as a [development dependency](../reference/specifying-dependencies.html#development-dependencies).
25+
{{/option}}
26+
27+
{{#option "`--build`" }}
28+
Remove as a [build dependency](../reference/specifying-dependencies.html#build-dependencies).
29+
{{/option}}
30+
31+
{{#option "`--target` _target_" }}
32+
Remove as a dependency to the [given target platform](../reference/specifying-dependencies.html#platform-specific-dependencies).
33+
{{/option}}
34+
35+
{{/options}}
36+
37+
### Miscellaneous Options
38+
39+
{{#options}}
40+
41+
{{#option "`--dry-run`" }}
42+
Don't actually write to the manifest.
43+
{{/option}}
44+
45+
{{/options}}
46+
47+
### Display Options
48+
49+
{{#options}}
50+
{{> options-display }}
51+
{{/options}}
52+
53+
### Manifest Options
54+
55+
{{#options}}
56+
{{> options-manifest-path }}
57+
58+
{{> options-locked }}
59+
{{/options}}
60+
61+
### Package Selection
62+
63+
{{#options}}
64+
65+
{{#option "`-p` _spec_..." "`--package` _spec_..." }}
66+
Package to remove from.
67+
{{/option}}
68+
69+
{{/options}}
70+
71+
{{> section-options-common }}
72+
73+
{{> section-environment }}
74+
75+
{{> section-exit-status }}
76+
77+
## EXAMPLES
78+
79+
1. Remove `regex` as a dependency
80+
81+
cargo remove regex
82+
83+
2. Remove `trybuild` as a dev-dependency
84+
85+
cargo remove --dev trybuild
86+
87+
3. Remove `nom` from the `x86_64-pc-windows-gnu` dependencies table
88+
89+
cargo remove --target x86_64-pc-windows-gnu nom
90+
91+
## SEE ALSO
92+
{{man "cargo" 1}}, {{man "cargo-add" 1}}

src/doc/man/generated_txt/cargo-add.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,5 @@ EXAMPLES
188188
cargo add serde serde_json -F serde/derive
189189

190190
SEE ALSO
191-
cargo(1)
191+
cargo(1), cargo-remove(1)
192192

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
CARGO-REMOVE(1)
2+
3+
NAME
4+
cargo-remove - Remove dependencies from a Cargo.toml manifest file
5+
6+
SYNOPSIS
7+
cargo remove [options] dependency...
8+
9+
DESCRIPTION
10+
Remove one or more dependencies from a Cargo.toml manifest.
11+
12+
OPTIONS
13+
Section options
14+
--dev
15+
Remove as a development dependency
16+
<https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#development-dependencies>.
17+
18+
--build
19+
Remove as a build dependency
20+
<https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#build-dependencies>.
21+
22+
--target target
23+
Remove as a dependency to the given target platform
24+
<https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies>.
25+
26+
Miscellaneous Options
27+
--dry-run
28+
Don't actually write to the manifest.
29+
30+
Display Options
31+
-v, --verbose
32+
Use verbose output. May be specified twice for "very verbose" output
33+
which includes extra output such as dependency warnings and build
34+
script output. May also be specified with the term.verbose config
35+
value <https://doc.rust-lang.org/cargo/reference/config.html>.
36+
37+
-q, --quiet
38+
Do not print cargo log messages. May also be specified with the
39+
term.quiet config value
40+
<https://doc.rust-lang.org/cargo/reference/config.html>.
41+
42+
--color when
43+
Control when colored output is used. Valid values:
44+
45+
o auto (default): Automatically detect if color support is
46+
available on the terminal.
47+
48+
o always: Always display colors.
49+
50+
o never: Never display colors.
51+
52+
May also be specified with the term.color config value
53+
<https://doc.rust-lang.org/cargo/reference/config.html>.
54+
55+
Manifest Options
56+
--manifest-path path
57+
Path to the Cargo.toml file. By default, Cargo searches for the
58+
Cargo.toml file in the current directory or any parent directory.
59+
60+
--frozen, --locked
61+
Either of these flags requires that the Cargo.lock file is
62+
up-to-date. If the lock file is missing, or it needs to be updated,
63+
Cargo will exit with an error. The --frozen flag also prevents Cargo
64+
from attempting to access the network to determine if it is
65+
out-of-date.
66+
67+
These may be used in environments where you want to assert that the
68+
Cargo.lock file is up-to-date (such as a CI build) or want to avoid
69+
network access.
70+
71+
--offline
72+
Prevents Cargo from accessing the network for any reason. Without
73+
this flag, Cargo will stop with an error if it needs to access the
74+
network and the network is not available. With this flag, Cargo will
75+
attempt to proceed without the network if possible.
76+
77+
Beware that this may result in different dependency resolution than
78+
online mode. Cargo will restrict itself to crates that are
79+
downloaded locally, even if there might be a newer version as
80+
indicated in the local copy of the index. See the cargo-fetch(1)
81+
command to download dependencies before going offline.
82+
83+
May also be specified with the net.offline config value
84+
<https://doc.rust-lang.org/cargo/reference/config.html>.
85+
86+
Package Selection
87+
-p spec..., --package spec...
88+
Package to remove from.
89+
90+
Common Options
91+
+toolchain
92+
If Cargo has been installed with rustup, and the first argument to
93+
cargo begins with +, it will be interpreted as a rustup toolchain
94+
name (such as +stable or +nightly). See the rustup documentation
95+
<https://rust-lang.github.io/rustup/overrides.html> for more
96+
information about how toolchain overrides work.
97+
98+
--config KEY=VALUE or PATH
99+
Overrides a Cargo configuration value. The argument should be in
100+
TOML syntax of KEY=VALUE, or provided as a path to an extra
101+
configuration file. This flag may be specified multiple times. See
102+
the command-line overrides section
103+
<https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
104+
for more information.
105+
106+
-h, --help
107+
Prints help information.
108+
109+
-Z flag
110+
Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
111+
details.
112+
113+
ENVIRONMENT
114+
See the reference
115+
<https://doc.rust-lang.org/cargo/reference/environment-variables.html>
116+
for details on environment variables that Cargo reads.
117+
118+
EXIT STATUS
119+
o 0: Cargo succeeded.
120+
121+
o 101: Cargo failed to complete.
122+
123+
EXAMPLES
124+
1. Remove regex as a dependency
125+
126+
cargo remove regex
127+
128+
2. Remove trybuild as a dev-dependency
129+
130+
cargo remove --dev trybuild
131+
132+
3. Remove nom from the x86_64-pc-windows-gnu dependencies table
133+
134+
cargo remove --target x86_64-pc-windows-gnu nom
135+
136+
SEE ALSO
137+
cargo(1), cargo-add(1)
138+

src/doc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
* [cargo locate-project](commands/cargo-locate-project.md)
6767
* [cargo metadata](commands/cargo-metadata.md)
6868
* [cargo pkgid](commands/cargo-pkgid.md)
69+
* [cargo remove](commands/cargo-remove.md)
6970
* [cargo tree](commands/cargo-tree.md)
7071
* [cargo update](commands/cargo-update.md)
7172
* [cargo vendor](commands/cargo-vendor.md)

src/doc/src/commands/cargo-add.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,4 @@ details on environment variables that Cargo reads.
231231
cargo add serde serde_json -F serde/derive
232232

233233
## SEE ALSO
234-
[cargo(1)](cargo.html)
234+
[cargo(1)](cargo.html), [cargo-remove(1)](cargo-remove.html)

0 commit comments

Comments
 (0)