Skip to content

Commit 3c35bf1

Browse files
committed
Auto merge of #11826 - weihanglo:cargo-add-target, r=epage
Notice for potential unexpected shell expansions in help text of `cargo-add`
2 parents d58902e + 4ec1885 commit 3c35bf1

File tree

8 files changed

+39
-10
lines changed

8 files changed

+39
-10
lines changed

src/doc/man/cargo-add.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,12 @@ Add as a [build dependency](../reference/specifying-dependencies.html#build-depe
8181

8282
{{#option "`--target` _target_" }}
8383
Add as a dependency to the [given target platform](../reference/specifying-dependencies.html#platform-specific-dependencies).
84+
85+
To avoid unexpected shell expansions, you may use quotes around each target, e.g., `--target 'cfg(unix)'`.
8486
{{/option}}
8587

8688
{{/options}}
8789

88-
89-
</dl>
90-
9190
### Dependency options
9291

9392
{{#options}}
@@ -169,5 +168,9 @@ Add dependencies to only the specified package.
169168

170169
cargo add serde serde_json -F serde/derive
171170

171+
5. Add `windows` as a platform specific dependency on `cfg(windows)`
172+
173+
cargo add windows --target 'cfg(windows)'
174+
172175
## SEE ALSO
173176
{{man "cargo" 1}}, {{man "cargo-remove" 1}}

src/doc/man/cargo-remove.md

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Remove as a [build dependency](../reference/specifying-dependencies.html#build-d
3030

3131
{{#option "`--target` _target_" }}
3232
Remove as a dependency to the [given target platform](../reference/specifying-dependencies.html#platform-specific-dependencies).
33+
34+
To avoid unexpected shell expansions, you may use quotes around each target, e.g., `--target 'cfg(unix)'`.
3335
{{/option}}
3436

3537
{{/options}}

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ OPTIONS
7676
Add as a dependency to the given target platform
7777
<https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies>.
7878

79-
</dl>
79+
To avoid unexpected shell expansions, you may use quotes around each
80+
target, e.g., --target 'cfg(unix)'.
8081

8182
Dependency options
8283
--dry-run
@@ -226,6 +227,10 @@ EXAMPLES
226227

227228
cargo add serde serde_json -F serde/derive
228229

230+
5. Add windows as a platform specific dependency on cfg(windows)
231+
232+
cargo add windows --target 'cfg(windows)'
233+
229234
SEE ALSO
230235
cargo(1), cargo-remove(1)
231236

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

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ OPTIONS
2323
Remove as a dependency to the given target platform
2424
<https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies>.
2525

26+
To avoid unexpected shell expansions, you may use quotes around each
27+
target, e.g., --target 'cfg(unix)'.
28+
2629
Miscellaneous Options
2730
--dry-run
2831
Don’t actually write to the manifest.

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,8 @@ which is defined by the <code>registry.default</code> config key which defaults
8686

8787

8888
<dt class="option-term" id="option-cargo-add---target"><a class="option-anchor" href="#option-cargo-add---target"></a><code>--target</code> <em>target</em></dt>
89-
<dd class="option-desc">Add as a dependency to the <a href="../reference/specifying-dependencies.html#platform-specific-dependencies">given target platform</a>.</dd>
90-
91-
92-
</dl>
89+
<dd class="option-desc">Add as a dependency to the <a href="../reference/specifying-dependencies.html#platform-specific-dependencies">given target platform</a>.</p>
90+
<p>To avoid unexpected shell expansions, you may use quotes around each target, e.g., <code>--target 'cfg(unix)'</code>.</dd>
9391

9492

9593
</dl>
@@ -272,5 +270,9 @@ details on environment variables that Cargo reads.
272270

273271
cargo add serde serde_json -F serde/derive
274272

273+
5. Add `windows` as a platform specific dependency on `cfg(windows)`
274+
275+
cargo add windows --target 'cfg(windows)'
276+
275277
## SEE ALSO
276278
[cargo(1)](cargo.html), [cargo-remove(1)](cargo-remove.html)

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Remove one or more dependencies from a `Cargo.toml` manifest.
2929

3030

3131
<dt class="option-term" id="option-cargo-remove---target"><a class="option-anchor" href="#option-cargo-remove---target"></a><code>--target</code> <em>target</em></dt>
32-
<dd class="option-desc">Remove as a dependency to the <a href="../reference/specifying-dependencies.html#platform-specific-dependencies">given target platform</a>.</dd>
32+
<dd class="option-desc">Remove as a dependency to the <a href="../reference/specifying-dependencies.html#platform-specific-dependencies">given target platform</a>.</p>
33+
<p>To avoid unexpected shell expansions, you may use quotes around each target, e.g., <code>--target 'cfg(unix)'</code>.</dd>
3334

3435

3536
</dl>

src/etc/man/cargo-add.1

+12-1
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ Add as a \fIbuild dependency\fR <https://doc.rust\-lang.org/cargo/reference/spec
9696
\fB\-\-target\fR \fItarget\fR
9797
.RS 4
9898
Add as a dependency to the \fIgiven target platform\fR <https://doc.rust\-lang.org/cargo/reference/specifying\-dependencies.html#platform\-specific\-dependencies>\&.
99+
.sp
100+
To avoid unexpected shell expansions, you may use quotes around each target, e.g., \fB\-\-target 'cfg(unix)'\fR\&.
99101
.RE
100-
</dl>
101102
.SS "Dependency options"
102103
.sp
103104
\fB\-\-dry\-run\fR
@@ -308,5 +309,15 @@ cargo add serde serde_json \-F serde/derive
308309
.fi
309310
.RE
310311
.RE
312+
.sp
313+
.RS 4
314+
\h'-04' 5.\h'+01'Add \fBwindows\fR as a platform specific dependency on \fBcfg(windows)\fR
315+
.sp
316+
.RS 4
317+
.nf
318+
cargo add windows \-\-target 'cfg(windows)'
319+
.fi
320+
.RE
321+
.RE
311322
.SH "SEE ALSO"
312323
\fBcargo\fR(1), \fBcargo\-remove\fR(1)

src/etc/man/cargo-remove.1

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Remove as a \fIbuild dependency\fR <https://doc.rust\-lang.org/cargo/reference/s
2525
\fB\-\-target\fR \fItarget\fR
2626
.RS 4
2727
Remove as a dependency to the \fIgiven target platform\fR <https://doc.rust\-lang.org/cargo/reference/specifying\-dependencies.html#platform\-specific\-dependencies>\&.
28+
.sp
29+
To avoid unexpected shell expansions, you may use quotes around each target, e.g., \fB\-\-target 'cfg(unix)'\fR\&.
2830
.RE
2931
.SS "Miscellaneous Options"
3032
.sp

0 commit comments

Comments
 (0)