@@ -39,17 +39,12 @@ fn print_available_targets(
39
39
let mut output = String :: new ( ) ;
40
40
writeln ! ( output, "\" {}\" takes one argument." , option_name) ?;
41
41
42
- print_availables ( output, & targets, plural_name)
43
- }
44
-
45
- fn print_availables ( output : String , availables : & [ & str ] , plural_name : & str ) -> CargoResult < ( ) > {
46
- let mut output = output;
47
- if availables. is_empty ( ) {
42
+ if targets. is_empty ( ) {
48
43
writeln ! ( output, "No {} available." , plural_name) ?;
49
44
} else {
50
45
writeln ! ( output, "Available {}:" , plural_name) ?;
51
- for available in availables {
52
- writeln ! ( output, " {}" , available ) ?;
46
+ for target in targets {
47
+ writeln ! ( output, " {}" , target ) ?;
53
48
}
54
49
}
55
50
bail ! ( "{}" , output)
@@ -61,16 +56,25 @@ pub fn print_available_packages(ws: &Workspace<'_>) -> CargoResult<()> {
61
56
. map ( |pkg| pkg. name ( ) . as_str ( ) )
62
57
. collect :: < Vec < _ > > ( ) ;
63
58
64
- let mut output = String :: new ( ) ;
65
- writeln ! (
66
- output,
67
- "\" --package <SPEC>\" requires a SPEC format value.\n \
68
- Run `cargo help pkgid` for more infomation about SPEC format."
69
- ) ?;
59
+ let mut output = "\" --package <SPEC>\" requires a SPEC format value, \
60
+ which can be any package ID specifier in the dependency graph.\n \
61
+ Run `cargo help pkgid` for more information about SPEC format.\n \n "
62
+ . to_string ( ) ;
70
63
71
- print_availables ( output, & packages, "packages" )
64
+ if packages. is_empty ( ) {
65
+ // This would never happen.
66
+ // Just in case something regresses we covers it here.
67
+ writeln ! ( output, "No packages available." ) ?;
68
+ } else {
69
+ writeln ! ( output, "Possible packages/workspace members:" ) ?;
70
+ for package in packages {
71
+ writeln ! ( output, " {}" , package) ?;
72
+ }
73
+ }
74
+ bail ! ( "{}" , output)
72
75
}
73
76
77
+
74
78
pub fn print_available_examples ( ws : & Workspace < ' _ > , options : & CompileOptions ) -> CargoResult < ( ) > {
75
79
print_available_targets ( Target :: is_example, ws, options, "--example" , "examples" )
76
80
}
0 commit comments