Skip to content

Commit f3a4448

Browse files
committed
Auto merge of #10575 - epage:version, r=weihanglo
fix(yank): Use '--version' like install ### What does this PR try to resolve? During the design conversations on cargo-add, we noticed: - `cargo-install` has a public flag `--version` and an invisible alias `--vers` - `cargo-yank` has a public flag `--vers` This switches `cargo-yank` to publicly use `--version` and have an invisible alias `--vers`, making it consistent with `cargo-install`. ### How should we test and review this PR? This updated all tests to use the "recommended" flag.
2 parents c85a71e + 2313edd commit f3a4448

File tree

14 files changed

+34
-31
lines changed

14 files changed

+34
-31
lines changed

Diff for: src/bin/cargo/commands/yank.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ pub fn cli() -> App {
88
.arg_quiet()
99
.arg(Arg::new("crate"))
1010
.arg(
11-
opt("vers", "The version to yank or un-yank")
11+
opt("version", "The version to yank or un-yank")
12+
.alias("vers")
1213
.value_name("VERSION")
1314
.required(true),
1415
)
@@ -30,7 +31,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
3031
ops::yank(
3132
config,
3233
args.value_of("crate").map(|s| s.to_string()),
33-
args.value_of("vers").map(|s| s.to_string()),
34+
args.value_of("version").map(|s| s.to_string()),
3435
args.value_of("token").map(|s| s.to_string()),
3536
args.value_of("index").map(|s| s.to_string()),
3637
args.is_present("undo"),

Diff for: src/cargo/ops/cargo_install.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -771,14 +771,14 @@ fn parse_semver_flag(v: &str) -> CargoResult<VersionReq> {
771771
let first = v
772772
.chars()
773773
.next()
774-
.ok_or_else(|| format_err!("no version provided for the `--vers` flag"))?;
774+
.ok_or_else(|| format_err!("no version provided for the `--version` flag"))?;
775775

776776
let is_req = "<>=^~".contains(first) || v.contains('*');
777777
if is_req {
778778
match v.parse::<VersionReq>() {
779779
Ok(v) => Ok(v),
780780
Err(_) => bail!(
781-
"the `--vers` provided, `{}`, is \
781+
"the `--version` provided, `{}`, is \
782782
not a valid semver version requirement\n\n\
783783
Please have a look at \
784784
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html \
@@ -791,7 +791,7 @@ fn parse_semver_flag(v: &str) -> CargoResult<VersionReq> {
791791
Ok(v) => Ok(VersionReq::exact(&v)),
792792
Err(e) => {
793793
let mut msg = format!(
794-
"the `--vers` provided, `{}`, is \
794+
"the `--version` provided, `{}`, is \
795795
not a valid semver version: {}\n",
796796
v, e
797797
);

Diff for: src/doc/man/cargo-yank.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cargo-yank - Remove a pushed crate from the index
66

77
## SYNOPSIS
88

9-
`cargo yank` [_options_] `--vers` _version_ [_crate_]
9+
`cargo yank` [_options_] `--version` _version_ [_crate_]
1010

1111
## DESCRIPTION
1212

@@ -30,7 +30,7 @@ current directory.
3030

3131
{{#options}}
3232

33-
{{#option "`--vers` _version_" }}
33+
{{#option "`--vers` _version_" "`--version` _version_" }}
3434
The version to yank or un-yank.
3535
{{/option}}
3636

@@ -64,7 +64,7 @@ Undo a yank, putting a version back into the index.
6464

6565
1. Yank a crate from the index:
6666

67-
cargo yank --vers 1.0.7 foo
67+
cargo yank --version 1.0.7 foo
6868

6969
## SEE ALSO
7070
{{man "cargo" 1}}, {{man "cargo-login" 1}}, {{man "cargo-publish" 1}}

Diff for: src/doc/man/generated_txt/cargo-yank.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ NAME
44
cargo-yank - Remove a pushed crate from the index
55

66
SYNOPSIS
7-
cargo yank [options] --vers version [crate]
7+
cargo yank [options] --version version [crate]
88

99
DESCRIPTION
1010
The yank command removes a previously published crate's version from the
@@ -23,7 +23,7 @@ DESCRIPTION
2323

2424
OPTIONS
2525
Yank Options
26-
--vers version
26+
--vers version, --version version
2727
The version to yank or un-yank.
2828

2929
--undo
@@ -104,7 +104,7 @@ EXIT STATUS
104104
EXAMPLES
105105
1. Yank a crate from the index:
106106

107-
cargo yank --vers 1.0.7 foo
107+
cargo yank --version 1.0.7 foo
108108

109109
SEE ALSO
110110
cargo(1), cargo-login(1), cargo-publish(1)

Diff for: src/doc/src/commands/cargo-yank.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cargo-yank - Remove a pushed crate from the index
66

77
## SYNOPSIS
88

9-
`cargo yank` [_options_] `--vers` _version_ [_crate_]
9+
`cargo yank` [_options_] `--version` _version_ [_crate_]
1010

1111
## DESCRIPTION
1212

@@ -31,6 +31,7 @@ current directory.
3131
<dl>
3232

3333
<dt class="option-term" id="option-cargo-yank---vers"><a class="option-anchor" href="#option-cargo-yank---vers"></a><code>--vers</code> <em>version</em></dt>
34+
<dt class="option-term" id="option-cargo-yank---version"><a class="option-anchor" href="#option-cargo-yank---version"></a><code>--version</code> <em>version</em></dt>
3435
<dd class="option-desc">The version to yank or un-yank.</dd>
3536

3637

@@ -139,7 +140,7 @@ details on environment variables that Cargo reads.
139140

140141
1. Yank a crate from the index:
141142

142-
cargo yank --vers 1.0.7 foo
143+
cargo yank --version 1.0.7 foo
143144

144145
## SEE ALSO
145146
[cargo(1)](cargo.html), [cargo-login(1)](cargo-login.html), [cargo-publish(1)](cargo-publish.html)

Diff for: src/doc/src/reference/publishing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ etc.). For situations such as this, Cargo supports a “yank” of a version of
142142
crate.
143143

144144
```console
145-
$ cargo yank --vers 1.0.1
146-
$ cargo yank --vers 1.0.1 --undo
145+
$ cargo yank --version 1.0.1
146+
$ cargo yank --version 1.0.1 --undo
147147
```
148148

149149
A yank **does not** delete any code. This feature is not intended for deleting

Diff for: src/etc/_cargo

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ _cargo() {
175175
'--rev=[specific commit to use when installing from git]:commit' \
176176
'--root=[directory to install packages into]: :_directories' \
177177
'--tag=[tag to use when installing from git]:tag' \
178-
'--vers=[version to install from crates.io]:version' \
178+
'--version='[version to install from crates.io]:version' \
179179
'--list[list all installed packages and their versions]' \
180180
'*: :_guard "^-*" "crate"'
181181
;;
@@ -332,7 +332,7 @@ _cargo() {
332332

333333
yank)
334334
_arguments -s -S $common $registry \
335-
'--vers=[specify yank version]:version' \
335+
'--version=[specify yank version]:version' \
336336
'--undo[undo a yank, putting a version back into the index]' \
337337
'--index=[specify registry index to yank from]:registry index' \
338338
'--token=[specify API token to use when authenticating]:token' \

Diff for: src/etc/cargo.bashcomp.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ _cargo()
8888
local opt__vendor="$opt_common $opt_mani $opt_lock $opt_sync --no-delete --respect-source-config --versioned-dirs"
8989
local opt__verify_project="$opt_common $opt_mani $opt_lock"
9090
local opt__version="$opt_common $opt_lock"
91-
local opt__yank="$opt_common $opt_lock --vers --undo --index --token --registry"
91+
local opt__yank="$opt_common $opt_lock --version --undo --index --token --registry"
9292
local opt__libtest="--help --include-ignored --ignored --test --bench --list --logfile --nocapture --test-threads --skip -q --quiet --exact --color --format"
9393

9494
if [[ $cword -gt $dd_i ]]; then

Diff for: src/etc/man/cargo-yank.1

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.SH "NAME"
77
cargo\-yank \- Remove a pushed crate from the index
88
.SH "SYNOPSIS"
9-
\fBcargo yank\fR [\fIoptions\fR] \fB\-\-vers\fR \fIversion\fR [\fIcrate\fR]
9+
\fBcargo yank\fR [\fIoptions\fR] \fB\-\-version\fR \fIversion\fR [\fIcrate\fR]
1010
.SH "DESCRIPTION"
1111
The yank command removes a previously published crate's version from the
1212
server's index. This command does not delete any data, and the crate will
@@ -24,7 +24,8 @@ current directory.
2424
.SH "OPTIONS"
2525
.SS "Yank Options"
2626
.sp
27-
\fB\-\-vers\fR \fIversion\fR
27+
\fB\-\-vers\fR \fIversion\fR,
28+
\fB\-\-version\fR \fIversion\fR
2829
.RS 4
2930
The version to yank or un\-yank.
3031
.RE
@@ -138,7 +139,7 @@ details on environment variables that Cargo reads.
138139
.sp
139140
.RS 4
140141
.nf
141-
cargo yank \-\-vers 1.0.7 foo
142+
cargo yank \-\-version 1.0.7 foo
142143
.fi
143144
.RE
144145
.RE

Diff for: tests/testsuite/alt_registry.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ Caused by:
647647
"owner",
648648
"publish",
649649
"search",
650-
"yank --vers 0.0.1",
650+
"yank --version 0.0.1",
651651
] {
652652
p.cargo(cmd)
653653
.arg("--registry")
@@ -726,12 +726,12 @@ fn no_api() {
726726
.with_stderr_contains(&err)
727727
.run();
728728

729-
p.cargo("yank --registry alternative --vers=0.0.1 bar")
729+
p.cargo("yank --registry alternative --version=0.0.1 bar")
730730
.with_status(101)
731731
.with_stderr_contains(&err)
732732
.run();
733733

734-
p.cargo("yank --registry alternative --vers=0.0.1 bar")
734+
p.cargo("yank --registry alternative --version=0.0.1 bar")
735735
.with_stderr_contains(&err)
736736
.with_status(101)
737737
.run();
@@ -1311,7 +1311,7 @@ Caused by:
13111311
#[cargo_test]
13121312
fn both_index_and_registry() {
13131313
let p = project().file("src/lib.rs", "").build();
1314-
for cmd in &["publish", "owner", "search", "yank --vers 1.0.0"] {
1314+
for cmd in &["publish", "owner", "search", "yank --version 1.0.0"] {
13151315
p.cargo(cmd)
13161316
.arg("--registry=foo")
13171317
.arg("--index=foo")

Diff for: tests/testsuite/credential_process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ token for `crates-io` has been erased!
356356
fn yank() {
357357
let (p, t) = get_token_test();
358358

359-
p.cargo("yank --vers 0.1.0 --registry alternative -Z credential-process")
359+
p.cargo("yank --version 0.1.0 --registry alternative -Z credential-process")
360360
.masquerade_as_nightly_cargo()
361361
.with_stderr(
362362
"\

Diff for: tests/testsuite/install.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ want to simply build the package.
338338
#[cargo_test]
339339
fn bad_version() {
340340
pkg("foo", "0.0.1");
341-
cargo_process("install foo --vers=0.2.0")
341+
cargo_process("install foo --version=0.2.0")
342342
.with_status(101)
343343
.with_stderr(
344344
"\
@@ -942,7 +942,7 @@ fn list() {
942942

943943
cargo_process("install --list").with_stdout("").run();
944944

945-
cargo_process("install bar --vers =0.2.1").run();
945+
cargo_process("install bar --version =0.2.1").run();
946946
cargo_process("install foo").run();
947947
cargo_process("install --list")
948948
.with_stdout(

Diff for: tests/testsuite/install_upgrade.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ fn ambiguous_version_no_longer_allowed() {
231231
cargo_process("install foo --version=1.0")
232232
.with_stderr(
233233
"\
234-
[ERROR] the `--vers` provided, `1.0`, is not a valid semver version: cannot parse '1.0' as a semver
234+
[ERROR] the `--version` provided, `1.0`, is not a valid semver version: cannot parse '1.0' as a semver
235235
236236
if you want to specify semver range, add an explicit qualifier, like ^1.0
237237
",

Diff for: tests/testsuite/yank.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ fn simple() {
3232
.file("src/main.rs", "fn main() {}")
3333
.build();
3434

35-
p.cargo("yank --vers 0.0.1 --token sekrit").run();
35+
p.cargo("yank --version 0.0.1 --token sekrit").run();
3636

37-
p.cargo("yank --undo --vers 0.0.1 --token sekrit")
37+
p.cargo("yank --undo --version 0.0.1 --token sekrit")
3838
.with_status(101)
3939
.with_stderr(
4040
" Updating `[..]` index

0 commit comments

Comments
 (0)