Skip to content

Commit 5095356

Browse files
committed
Make the public/no-public next to the pair optional/no-optional
1 parent 58e0ab8 commit 5095356

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

src/bin/cargo/commands/add.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ The package name will be exposed as feature of your crate.")
6262
The package will be removed from your features.")
6363
.conflicts_with("dev")
6464
.overrides_with("optional"),
65+
flag("public", "Mark the dependency as public")
66+
.long_help("Mark the dependency as public
67+
68+
The dependnecy will be visible in both of your crate and outside."),
69+
flag("no-public", "Mark the dependency as private")
70+
.conflicts_with("dev")
71+
.conflicts_with("build")
72+
.overrides_with("public")
73+
.long_help("Mark the dependency as private
74+
75+
The dependnecy will be only visible in your crate other than outside."),
6576
clap::Arg::new("rename")
6677
.long("rename")
6778
.action(ArgAction::Set)
@@ -76,18 +87,6 @@ Example uses:
7687
"ignore-rust-version",
7788
"Ignore `rust-version` specification in packages (unstable)"
7889
),
79-
flag("public", "Mark the dependency as public")
80-
.long_help("Mark the dependency as public
81-
82-
The dependnecy will be visible in both of your crate and outside."),
83-
flag("no-public", "Mark the dependency as private")
84-
.conflicts_with("dev")
85-
.long_help("Mark the dependency as private
86-
87-
The dependnecy will be only visible in your crate other than outside.")
88-
.conflicts_with("dev")
89-
.overrides_with("public"),
90-
9190
])
9291
.arg_manifest_path_without_unsupported_path_tip()
9392
.arg_package("Package to modify")

src/cargo/util/toml_mut/dependency.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ impl Dependency {
5151
Self {
5252
name: name.into(),
5353
optional: None,
54+
public: None,
5455
features: None,
5556
default_features: None,
5657
inherited_features: None,
5758
source: None,
5859
registry: None,
5960
rename: None,
60-
public: None,
6161
}
6262
}
6363

@@ -338,14 +338,14 @@ impl Dependency {
338338

339339
let dep = Self {
340340
name,
341-
rename,
342-
source: Some(source),
343-
registry,
344-
default_features,
345-
features,
346341
optional,
347342
public,
343+
features,
344+
default_features,
348345
inherited_features: None,
346+
source: Some(source),
347+
registry,
348+
rename,
349349
};
350350
Ok(dep)
351351
} else {

tests/testsuite/cargo_add/help/stdout.log

+10-10
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@ Options:
3232

3333
The package will be removed from your features.
3434

35-
--rename <NAME>
36-
Rename the dependency
37-
38-
Example uses:
39-
- Depending on multiple versions of a crate
40-
- Depend on crates with the same name from different registries
41-
42-
--ignore-rust-version
43-
Ignore `rust-version` specification in packages (unstable)
44-
4535
--public
4636
Mark the dependency as public
4737

@@ -52,6 +42,16 @@ Options:
5242

5343
The dependnecy will be only visible in your crate other than outside.
5444

45+
--rename <NAME>
46+
Rename the dependency
47+
48+
Example uses:
49+
- Depending on multiple versions of a crate
50+
- Depend on crates with the same name from different registries
51+
52+
--ignore-rust-version
53+
Ignore `rust-version` specification in packages (unstable)
54+
5555
-n, --dry-run
5656
Don't actually write the manifest
5757

0 commit comments

Comments
 (0)