File tree 2 files changed +33
-9
lines changed
2 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -158,20 +158,14 @@ fn resolve_dependencies(context: &CliContext) -> Vec<ResolvedDependency> {
158
158
) ;
159
159
if !resolution. is_success ( ) {
160
160
eprintln ! ( "Failed to resolve all dependencies" ) ;
161
+ let req_error_messages = resolution. req_error_messages ( ) ;
161
162
162
163
for d in resolution. failed {
163
164
eprintln ! ( " {d}" ) ;
164
165
}
165
166
166
- for ( name, requirements) in resolution. req_failures {
167
- eprintln ! (
168
- " {name}: {}" ,
169
- requirements
170
- . iter( )
171
- . map( |x| x. to_string( ) )
172
- . collect:: <Vec <_>>( )
173
- . join( ", " )
174
- ) ;
167
+ if !req_error_messages. is_empty ( ) {
168
+ eprintln ! ( "{}" , req_error_messages. join( "\n " ) ) ;
175
169
}
176
170
177
171
:: std:: process:: exit ( 1 )
Original file line number Diff line number Diff line change @@ -95,4 +95,34 @@ impl<'d> Resolution<'d> {
95
95
pub fn is_success ( & self ) -> bool {
96
96
self . failed . is_empty ( ) && self . req_failures . is_empty ( )
97
97
}
98
+
99
+ pub fn req_error_messages ( & self ) -> Vec < String > {
100
+ self . req_failures
101
+ . iter ( )
102
+ . map ( |( name, reqs) | {
103
+ let versions_msg = self
104
+ . found
105
+ . iter ( )
106
+ . filter ( |f| f. name == name. as_ref ( ) )
107
+ . map ( |x| format ! ( " * {} (from {})" , x. version. original, x. source) )
108
+ . collect :: < Vec < _ > > ( )
109
+ . join ( "\n " ) ;
110
+
111
+ let reqs_msg = reqs
112
+ . iter ( )
113
+ . map ( |x| x. to_string ( ) )
114
+ . collect :: < Vec < _ > > ( )
115
+ . join ( ", " ) ;
116
+
117
+ if versions_msg. is_empty ( ) {
118
+ format ! ( "{}:\n - {} and no versions were found" , name, reqs_msg)
119
+ } else {
120
+ format ! (
121
+ "{}:\n - {} and the following version(s) were found:\n {}" ,
122
+ name, reqs_msg, versions_msg
123
+ )
124
+ }
125
+ } )
126
+ . collect ( )
127
+ }
98
128
}
You can’t perform that action at this time.
0 commit comments