@@ -5,6 +5,8 @@ extern crate cargo;
5
5
extern crate crates_io;
6
6
extern crate env_logger;
7
7
extern crate getopts;
8
+ #[ macro_use]
9
+ extern crate log;
8
10
9
11
use crates_io:: { Crate , Registry } ;
10
12
@@ -61,6 +63,8 @@ impl<'a> SourceInfo<'a> {
61
63
let source_id = SourceId :: crates_io ( config) ?;
62
64
let source = source_id. load ( config) ;
63
65
66
+ debug ! ( "source id loaded: {:?}" , source_id) ;
67
+
64
68
Ok ( SourceInfo {
65
69
id : source_id,
66
70
source : source,
@@ -99,6 +103,7 @@ impl<'a> WorkInfo<'a> {
99
103
// TODO: fall back to locally cached package instance, or better yet, search for it
100
104
// first.
101
105
let package_id = PackageId :: new ( info. name , info. version , & source. id ) ?;
106
+ debug ! ( "(remote) package id: {:?}" , package_id) ;
102
107
let package = source. source . download ( & package_id) ?;
103
108
let workspace = Workspace :: ephemeral ( package. clone ( ) , config, None , false ) ?;
104
109
@@ -130,7 +135,7 @@ impl<'a> WorkInfo<'a> {
130
135
/// and/or defaults, and dispatch the actual analysis.
131
136
// TODO: possibly reduce the complexity by finding where some info can be taken from directly
132
137
fn do_main ( config : & Config , matches : & Matches ) -> CargoResult < ( ) > {
133
- fn parse_arg ( opt : & str ) -> CargoResult < ( & str , & str ) > {
138
+ fn parse_arg ( opt : & str ) -> CargoResult < NameAndVersion > {
134
139
let mut split = opt. split ( '-' ) ;
135
140
let name = if let Some ( n) = split. next ( ) {
136
141
n
@@ -147,29 +152,26 @@ fn do_main(config: &Config, matches: &Matches) -> CargoResult<()> {
147
152
return Err ( "spec has to be of form `name-version`" . into ( ) ) ;
148
153
}
149
154
150
- Ok ( ( name, version) )
155
+ Ok ( NameAndVersion { name : name , version : version } )
151
156
}
152
157
153
158
let mut source = SourceInfo :: new ( config) ?;
154
159
155
160
let current = if let Some ( opt) = matches. opt_str ( "C" ) {
156
- let ( name, version) = parse_arg ( & opt) ?;
157
-
158
- let info = NameAndVersion { name : name, version : version } ;
159
- WorkInfo :: remote ( config, & mut source, info) ?
161
+ WorkInfo :: remote ( config, & mut source, parse_arg ( & opt) ?) ?
160
162
} else {
161
163
WorkInfo :: local ( config, matches. opt_str ( "c" ) . map ( PathBuf :: from) ) ?
162
164
} ;
163
165
164
166
let name = current. package . name ( ) . to_owned ( ) ;
165
167
166
168
let ( stable, stable_version) = if let Some ( opt) = matches. opt_str ( "S" ) {
167
- let ( name, version) = parse_arg ( & opt) ?;
169
+ let info = parse_arg ( & opt) ?;
170
+ let version = info. version . to_owned ( ) ;
168
171
169
- let info = NameAndVersion { name : name, version : version } ;
170
172
let work_info = WorkInfo :: remote ( config, & mut source, info) ?;
171
173
172
- ( work_info, version. to_owned ( ) )
174
+ ( work_info, version)
173
175
} else if let Some ( path) = matches. opt_str ( "s" ) {
174
176
let work_info = WorkInfo :: local ( config, Some ( PathBuf :: from ( path) ) ) ?;
175
177
let version = format ! ( "{}" , work_info. package. version( ) ) ;
0 commit comments