Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support abbreviating --release as -r #10133

Merged
merged 2 commits into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub trait AppExt: Sized {
}

fn arg_release(self, release: &'static str) -> Self {
self._arg(opt("release", release))
self._arg(opt("release", release).short("r"))
}

fn arg_profile(self, profile: &'static str) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/generated_txt/cargo-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ OPTIONS
<https://doc.rust-lang.org/cargo/guide/build-cache.html>
documentation for more details.

--release
-r, --release
Build optimized artifacts with the release profile. See also the
--profile option for choosing a specific profile by name.

Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/generated_txt/cargo-check.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ OPTIONS
<https://doc.rust-lang.org/cargo/guide/build-cache.html>
documentation for more details.

--release
-r, --release
Check optimized artifacts with the release profile. See also the
--profile option for choosing a specific profile by name.

Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/generated_txt/cargo-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ OPTIONS
<https://doc.rust-lang.org/cargo/guide/build-cache.html>
documentation for more details.

--release
-r, --release
Document optimized artifacts with the release profile. See also the
--profile option for choosing a specific profile by name.

Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/generated_txt/cargo-fix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ OPTIONS
<https://doc.rust-lang.org/cargo/guide/build-cache.html>
documentation for more details.

--release
-r, --release
Fix optimized artifacts with the release profile. See also the
--profile option for choosing a specific profile by name.

Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/generated_txt/cargo-run.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ OPTIONS
<https://doc.rust-lang.org/cargo/guide/build-cache.html>
documentation for more details.

--release
-r, --release
Run optimized artifacts with the release profile. See also the
--profile option for choosing a specific profile by name.

Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/generated_txt/cargo-rustc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ OPTIONS
<https://doc.rust-lang.org/cargo/guide/build-cache.html>
documentation for more details.

--release
-r, --release
Build optimized artifacts with the release profile. See also the
--profile option for choosing a specific profile by name.

Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/generated_txt/cargo-rustdoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ OPTIONS
<https://doc.rust-lang.org/cargo/guide/build-cache.html>
documentation for more details.

--release
-r, --release
Document optimized artifacts with the release profile. See also the
--profile option for choosing a specific profile by name.

Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/generated_txt/cargo-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ OPTIONS
<https://doc.rust-lang.org/cargo/guide/build-cache.html>
documentation for more details.

--release
-r, --release
Test optimized artifacts with the release profile. See also the
--profile option for choosing a specific profile by name.

Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/includes/options-release.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{#option "`--release`"}}
{{#option "`-r`" "`--release`"}}
{{actionverb}} optimized artifacts with the `release` profile.
See also the `--profile` option for choosing a specific profile by name.
{{/option}}
1 change: 1 addition & 0 deletions src/doc/src/commands/cargo-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ target artifacts are placed in a separate directory. See the



<dt class="option-term" id="option-cargo-build--r"><a class="option-anchor" href="#option-cargo-build--r"></a><code>-r</code></dt>
<dt class="option-term" id="option-cargo-build---release"><a class="option-anchor" href="#option-cargo-build---release"></a><code>--release</code></dt>
<dd class="option-desc">Build optimized artifacts with the <code>release</code> profile.
See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
Expand Down
1 change: 1 addition & 0 deletions src/doc/src/commands/cargo-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ target artifacts are placed in a separate directory. See the



<dt class="option-term" id="option-cargo-check--r"><a class="option-anchor" href="#option-cargo-check--r"></a><code>-r</code></dt>
<dt class="option-term" id="option-cargo-check---release"><a class="option-anchor" href="#option-cargo-check---release"></a><code>--release</code></dt>
<dd class="option-desc">Check optimized artifacts with the <code>release</code> profile.
See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
Expand Down
1 change: 1 addition & 0 deletions src/doc/src/commands/cargo-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ target artifacts are placed in a separate directory. See the



<dt class="option-term" id="option-cargo-doc--r"><a class="option-anchor" href="#option-cargo-doc--r"></a><code>-r</code></dt>
<dt class="option-term" id="option-cargo-doc---release"><a class="option-anchor" href="#option-cargo-doc---release"></a><code>--release</code></dt>
<dd class="option-desc">Document optimized artifacts with the <code>release</code> profile.
See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
Expand Down
1 change: 1 addition & 0 deletions src/doc/src/commands/cargo-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ target artifacts are placed in a separate directory. See the



<dt class="option-term" id="option-cargo-fix--r"><a class="option-anchor" href="#option-cargo-fix--r"></a><code>-r</code></dt>
<dt class="option-term" id="option-cargo-fix---release"><a class="option-anchor" href="#option-cargo-fix---release"></a><code>--release</code></dt>
<dd class="option-desc">Fix optimized artifacts with the <code>release</code> profile.
See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
Expand Down
1 change: 1 addition & 0 deletions src/doc/src/commands/cargo-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ target artifacts are placed in a separate directory. See the



<dt class="option-term" id="option-cargo-run--r"><a class="option-anchor" href="#option-cargo-run--r"></a><code>-r</code></dt>
<dt class="option-term" id="option-cargo-run---release"><a class="option-anchor" href="#option-cargo-run---release"></a><code>--release</code></dt>
<dd class="option-desc">Run optimized artifacts with the <code>release</code> profile.
See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
Expand Down
1 change: 1 addition & 0 deletions src/doc/src/commands/cargo-rustc.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ target artifacts are placed in a separate directory. See the



<dt class="option-term" id="option-cargo-rustc--r"><a class="option-anchor" href="#option-cargo-rustc--r"></a><code>-r</code></dt>
<dt class="option-term" id="option-cargo-rustc---release"><a class="option-anchor" href="#option-cargo-rustc---release"></a><code>--release</code></dt>
<dd class="option-desc">Build optimized artifacts with the <code>release</code> profile.
See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
Expand Down
1 change: 1 addition & 0 deletions src/doc/src/commands/cargo-rustdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ target artifacts are placed in a separate directory. See the



<dt class="option-term" id="option-cargo-rustdoc--r"><a class="option-anchor" href="#option-cargo-rustdoc--r"></a><code>-r</code></dt>
<dt class="option-term" id="option-cargo-rustdoc---release"><a class="option-anchor" href="#option-cargo-rustdoc---release"></a><code>--release</code></dt>
<dd class="option-desc">Document optimized artifacts with the <code>release</code> profile.
See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
Expand Down
1 change: 1 addition & 0 deletions src/doc/src/commands/cargo-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ target artifacts are placed in a separate directory. See the



<dt class="option-term" id="option-cargo-test--r"><a class="option-anchor" href="#option-cargo-test--r"></a><code>-r</code></dt>
<dt class="option-term" id="option-cargo-test---release"><a class="option-anchor" href="#option-cargo-test---release"></a><code>--release</code></dt>
<dd class="option-desc">Test optimized artifacts with the <code>release</code> profile.
See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
Expand Down
1 change: 1 addition & 0 deletions src/etc/man/cargo-build.1
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ target artifacts are placed in a separate directory. See the
\fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details.
.RE
.sp
\fB\-r\fR,
\fB\-\-release\fR
.RS 4
Build optimized artifacts with the \fBrelease\fR profile.
Expand Down
1 change: 1 addition & 0 deletions src/etc/man/cargo-check.1
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ target artifacts are placed in a separate directory. See the
\fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details.
.RE
.sp
\fB\-r\fR,
\fB\-\-release\fR
.RS 4
Check optimized artifacts with the \fBrelease\fR profile.
Expand Down
1 change: 1 addition & 0 deletions src/etc/man/cargo-doc.1
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ target artifacts are placed in a separate directory. See the
\fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details.
.RE
.sp
\fB\-r\fR,
\fB\-\-release\fR
.RS 4
Document optimized artifacts with the \fBrelease\fR profile.
Expand Down
1 change: 1 addition & 0 deletions src/etc/man/cargo-fix.1
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ target artifacts are placed in a separate directory. See the
\fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details.
.RE
.sp
\fB\-r\fR,
\fB\-\-release\fR
.RS 4
Fix optimized artifacts with the \fBrelease\fR profile.
Expand Down
1 change: 1 addition & 0 deletions src/etc/man/cargo-run.1
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ target artifacts are placed in a separate directory. See the
\fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details.
.RE
.sp
\fB\-r\fR,
\fB\-\-release\fR
.RS 4
Run optimized artifacts with the \fBrelease\fR profile.
Expand Down
1 change: 1 addition & 0 deletions src/etc/man/cargo-rustc.1
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ target artifacts are placed in a separate directory. See the
\fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details.
.RE
.sp
\fB\-r\fR,
\fB\-\-release\fR
.RS 4
Build optimized artifacts with the \fBrelease\fR profile.
Expand Down
1 change: 1 addition & 0 deletions src/etc/man/cargo-rustdoc.1
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ target artifacts are placed in a separate directory. See the
\fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details.
.RE
.sp
\fB\-r\fR,
\fB\-\-release\fR
.RS 4
Document optimized artifacts with the \fBrelease\fR profile.
Expand Down
1 change: 1 addition & 0 deletions src/etc/man/cargo-test.1
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ target artifacts are placed in a separate directory. See the
\fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details.
.RE
.sp
\fB\-r\fR,
\fB\-\-release\fR
.RS 4
Test optimized artifacts with the \fBrelease\fR profile.
Expand Down
19 changes: 19 additions & 0 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,25 @@ fn verbose_release_build() {
.run();
}

#[cargo_test]
fn verbose_release_build_short() {
let p = project().file("src/lib.rs", "").build();
p.cargo("build -v -r")
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link[..]\
-C opt-level=3[..]\
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/release/deps`
[FINISHED] release [optimized] target(s) in [..]
",
)
.run();
}

#[cargo_test]
fn verbose_release_build_deps() {
let p = project()
Expand Down
23 changes: 23 additions & 0 deletions tests/testsuite/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,29 @@ fn release_works() {
assert!(p.release_bin("foo").is_file());
}

#[cargo_test]
fn release_short_works() {
let p = project()
.file(
"src/main.rs",
r#"
fn main() { if cfg!(debug_assertions) { panic!() } }
"#,
)
.build();

p.cargo("run -r")
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] `target/release/foo[EXE]`
",
)
.run();
assert!(p.release_bin("foo").is_file());
}

#[cargo_test]
fn run_bin_different_name() {
let p = project()
Expand Down