@@ -8,7 +8,7 @@ use crate::util::restricted_names::is_glob_pattern;
8
8
use crate :: util:: { paths, toml:: TomlProfile , validate_package_name} ;
9
9
use crate :: util:: {
10
10
print_available_benches, print_available_binaries, print_available_examples,
11
- print_available_tests,
11
+ print_available_packages , print_available_tests,
12
12
} ;
13
13
use crate :: CargoResult ;
14
14
use anyhow:: bail;
@@ -52,7 +52,7 @@ pub trait AppExt: Sized {
52
52
}
53
53
54
54
fn arg_package_spec_simple ( self , package : & ' static str ) -> Self {
55
- self . _arg ( multi_opt ( "package" , "SPEC" , package) . short ( "p" ) )
55
+ self . _arg ( optional_multi_opt ( "package" , "SPEC" , package) . short ( "p" ) )
56
56
}
57
57
58
58
fn arg_package ( self , package : & ' static str ) -> Self {
@@ -498,6 +498,13 @@ pub trait ArgMatchesExt {
498
498
499
499
if let Some ( ws) = workspace {
500
500
self . check_optional_opts ( ws, & opts) ?;
501
+ } else if self . is_present_with_zero_values ( "package" ) {
502
+ // As for cargo 0.50.0, this won't occur but if someone sneaks in
503
+ // we can still provide this informative message for them.
504
+ anyhow:: bail!(
505
+ "\" --package <SPEC>\" requires a SPEC format value.\n \
506
+ Run `cargo help pkgid` for more infomation about SPEC format."
507
+ )
501
508
}
502
509
503
510
Ok ( opts)
@@ -588,6 +595,10 @@ about this warning.";
588
595
workspace : & Workspace < ' _ > ,
589
596
compile_opts : & CompileOptions ,
590
597
) -> CargoResult < ( ) > {
598
+ if self . is_present_with_zero_values ( "package" ) {
599
+ print_available_packages ( workspace) ?
600
+ }
601
+
591
602
if self . is_present_with_zero_values ( "example" ) {
592
603
print_available_examples ( workspace, compile_opts) ?;
593
604
}
0 commit comments