Skip to content

Commit a838f8f

Browse files
committed
Fix read-manifest summary printing under cargo --list
1 parent af2c355 commit a838f8f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/bin/cargo/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
7272
match command {
7373
CommandInfo::BuiltIn { name, about } => {
7474
let summary = about.unwrap_or_default();
75+
let summary = summary.lines().next().unwrap_or(&summary); // display only the first line
7576
println!(" {:<20} {}", name, summary)
7677
}
7778
CommandInfo::External { name, path } => {

src/bin/cargo/commands/read_manifest.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ use cargo::print_json;
55
pub fn cli() -> App {
66
subcommand("read-manifest")
77
.about(
8-
"Deprecated, use `cargo metadata --no-deps` instead.
9-
Print a JSON representation of a Cargo.toml manifest.",
8+
"\
9+
Print a JSON representation of a Cargo.toml manifest.
10+
11+
Deprecated, use `cargo metadata --no-deps` instead.\
12+
",
1013
)
1114
.arg_manifest_path()
1215
}

tests/testsuite/cargo_command.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ fn list_commands_with_descriptions() {
7070
"missing build, with description: {}",
7171
output
7272
);
73+
// assert read-manifest prints the right one-line description followed by another command, indented.
74+
assert!(
75+
output.contains("\n read-manifest Print a JSON representation of a Cargo.toml manifest.\n "),
76+
"missing build, with description: {}",
77+
output
78+
);
7379
}
7480

7581
#[test]

0 commit comments

Comments
 (0)