@@ -35,7 +35,7 @@ pub struct Args {
3535 pub crates : Vec < String > ,
3636
3737 /// Rename a dependency in Cargo.toml,
38- /// https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml.
38+ /// < https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml> .
3939 /// Only works when specifying a single dependency.
4040 #[ structopt( long = "rename" , short = "r" ) ]
4141 pub rename : Option < String > ,
@@ -85,17 +85,11 @@ pub struct Args {
8585 pub optional : bool ,
8686
8787 /// Path to the manifest to add a dependency to.
88- #[ structopt( long = "manifest-path" , value_name = "path" , conflicts_with = "pkgid" ) ]
89- pub manifest_path : Option < PathBuf > ,
88+ #[ structopt( flatten ) ]
89+ pub manifest : clap_cargo :: Manifest ,
9090
91- /// Package id of the crate to add this dependency to.
92- #[ structopt(
93- long = "package" ,
94- short = "p" ,
95- value_name = "pkgid" ,
96- conflicts_with = "path"
97- ) ]
98- pub pkgid : Option < String > ,
91+ #[ structopt( flatten) ]
92+ pub workspace : clap_cargo:: Workspace ,
9993
10094 /// Choose method of semantic version upgrade. Must be one of "none" (exact version, `=`
10195 /// modifier), "patch" (`~` modifier), "minor" (`^` modifier), "all" (`>=`), or "default" (no
@@ -117,14 +111,9 @@ pub struct Args {
117111 #[ structopt( long = "allow-prerelease" ) ]
118112 pub allow_prerelease : bool ,
119113
120- /// Space-separated list of features to add. For an alternative approach to
121- /// enabling features, consider installing the `cargo-feature` utility.
122- #[ structopt( long = "features" , number_of_values = 1 ) ]
123- pub features : Option < Vec < String > > ,
124-
125- /// Set `default-features = false` for the added dependency.
126- #[ structopt( long = "no-default-features" ) ]
127- pub no_default_features : bool ,
114+ /// For an alternative approach to enabling features, consider installing `cargo-feature`.
115+ #[ structopt( flatten) ]
116+ pub features : clap_cargo:: Features ,
128117
129118 /// Do not print any output in case of success.
130119 #[ structopt( long = "quiet" , short = "q" ) ]
@@ -229,7 +218,10 @@ impl Args {
229218 dependency = dependency. set_version ( parse_version_req ( version) ?) ;
230219 }
231220 let registry_url = if let Some ( registry) = & self . registry {
232- Some ( registry_url ( & find ( & self . manifest_path ) ?, Some ( registry) ) ?)
221+ Some ( registry_url (
222+ & find ( & self . manifest . manifest_path ) ?,
223+ Some ( registry) ,
224+ ) ?)
233225 } else {
234226 None
235227 } ;
@@ -262,7 +254,7 @@ impl Args {
262254 dependency = get_latest_dependency (
263255 crate_name. name ( ) ,
264256 self . allow_prerelease ,
265- & find ( & self . manifest_path ) ?,
257+ & find ( & self . manifest . manifest_path ) ?,
266258 & registry_url,
267259 ) ?;
268260 let v = format ! (
@@ -287,7 +279,7 @@ impl Args {
287279
288280 /// Build dependencies from arguments
289281 pub fn parse_dependencies ( & self ) -> Result < Vec < Dependency > > {
290- let workspace_members = workspace_members ( self . manifest_path . as_deref ( ) ) ?;
282+ let workspace_members = workspace_members ( self . manifest . manifest_path . as_deref ( ) ) ?;
291283
292284 if self . crates . len ( ) > 1
293285 && ( self . git . is_some ( ) || self . path . is_some ( ) || self . vers . is_some ( ) )
@@ -299,7 +291,7 @@ impl Args {
299291 return Err ( ErrorKind :: MultipleCratesWithRename . into ( ) ) ;
300292 }
301293
302- if self . crates . len ( ) > 1 && self . features . is_some ( ) {
294+ if self . crates . len ( ) > 1 && ! self . features . features . is_empty ( ) {
303295 return Err ( ErrorKind :: MultipleCratesWithFeatures . into ( ) ) ;
304296 }
305297
@@ -310,8 +302,12 @@ impl Args {
310302 . map ( |x| {
311303 let mut x = x
312304 . set_optional ( self . optional )
313- . set_features ( self . features . clone ( ) )
314- . set_default_features ( !self . no_default_features ) ;
305+ . set_features ( if self . features . features . is_empty ( ) {
306+ None
307+ } else {
308+ Some ( self . features . features . clone ( ) )
309+ } )
310+ . set_default_features ( !self . features . no_default_features ) ;
315311 if let Some ( ref rename) = self . rename {
316312 x = x. set_rename ( rename) ;
317313 }
@@ -347,16 +343,15 @@ impl Default for Args {
347343 path : None ,
348344 target : None ,
349345 optional : false ,
350- manifest_path : None ,
351- pkgid : None ,
352346 upgrade : "minor" . to_string ( ) ,
353347 allow_prerelease : false ,
354- features : None ,
355- no_default_features : false ,
356348 quiet : false ,
357349 offline : true ,
358350 sort : false ,
359351 registry : None ,
352+ manifest : Default :: default ( ) ,
353+ workspace : Default :: default ( ) ,
354+ features : Default :: default ( ) ,
360355 }
361356 }
362357}
0 commit comments