Skip to content

Commit bc472c7

Browse files
committed
Change format character to 'lib'.
1 parent 7595a25 commit bc472c7

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

src/cargo/ops/tree/format/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl Pattern {
2929
RawChunk::Argument("l") => Chunk::License,
3030
RawChunk::Argument("r") => Chunk::Repository,
3131
RawChunk::Argument("f") => Chunk::Features,
32-
RawChunk::Argument("n") => Chunk::Name,
32+
RawChunk::Argument("lib") => Chunk::Name,
3333
RawChunk::Argument(a) => {
3434
bail!("unsupported pattern `{}`", a);
3535
}

src/cargo/ops/tree/format/parse.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Parser for the `--format` string for `cargo tree`.
22
3-
use std::{iter, str};
3+
use std::iter;
4+
use std::str;
45

56
pub enum RawChunk<'a> {
67
/// Raw text to include in the output.

tests/testsuite/tree.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ foo v0.1.0 ([..]/foo)
10091009
#[cargo_test]
10101010
fn format() {
10111011
Package::new("dep", "1.0.0").publish();
1012+
10121013
Package::new("dep_that_is_awesome", "1.0.0")
10131014
.file(
10141015
"Cargo.toml",
@@ -1036,7 +1037,7 @@ fn format() {
10361037
10371038
[dependencies]
10381039
dep = {version="1.0", optional=true}
1039-
dep_that_is_awesome = {version="1.0"}
1040+
dep_that_is_awesome = {version="1.0", optional=true}
10401041
10411042
[features]
10421043
default = ["foo"]
@@ -1048,9 +1049,7 @@ fn format() {
10481049
.build();
10491050

10501051
p.cargo("tree --format <<<{p}>>>")
1051-
.with_stdout("\
1052-
<<<foo v0.1.0 ([..]/foo)>>>
1053-
└── <<<dep_that_is_awesome v1.0.0>>>")
1052+
.with_stdout("<<<foo v0.1.0 ([..]/foo)>>>")
10541053
.run();
10551054

10561055
p.cargo("tree --format {}")
@@ -1066,42 +1065,40 @@ Caused by:
10661065
.run();
10671066

10681067
p.cargo("tree --format {p}-{{hello}}")
1069-
.with_stdout("\
1070-
foo v0.1.0 ([..]/foo)-{hello}
1071-
└── dep_that_is_awesome v1.0.0-{hello}")
1068+
.with_stdout("foo v0.1.0 ([..]/foo)-{hello}")
10721069
.run();
10731070

10741071
p.cargo("tree --format")
10751072
.arg("{p} {l} {r}")
1076-
.with_stdout("\
1077-
foo v0.1.0 ([..]/foo) MIT https://github.com/rust-lang/cargo
1078-
└── dep_that_is_awesome v1.0.0 ")
1073+
.with_stdout("foo v0.1.0 ([..]/foo) MIT https://github.com/rust-lang/cargo")
10791074
.run();
10801075

10811076
p.cargo("tree --format")
10821077
.arg("{p} {f}")
1083-
.with_stdout("\
1084-
foo v0.1.0 ([..]/foo) bar,default,foo
1085-
└── dep_that_is_awesome v1.0.0 ")
1078+
.with_stdout("foo v0.1.0 ([..]/foo) bar,default,foo")
10861079
.run();
10871080

10881081
p.cargo("tree --all-features --format")
10891082
.arg("{p} [{f}]")
10901083
.with_stdout(
10911084
"\
1092-
foo v0.1.0 ([..]/foo) [bar,default,dep,foo]
1085+
foo v0.1.0 ([..]/foo) [bar,default,dep,dep_that_is_awesome,foo]
10931086
├── dep v1.0.0 []
10941087
└── dep_that_is_awesome v1.0.0 []
10951088
",
10961089
)
10971090
.run();
10981091

1099-
p.cargo("tree --format {n}")
1100-
.with_stdout("\
1092+
p.cargo("tree")
1093+
.arg("--features=dep_that_is_awesome")
1094+
.arg("--format={lib}")
1095+
.with_stdout(
1096+
"\
11011097
foo
1102-
└── awesome_dep")
1098+
└── awesome_dep
1099+
",
1100+
)
11031101
.run();
1104-
11051102
}
11061103

11071104
#[cargo_test]

0 commit comments

Comments
 (0)