@@ -5,14 +5,15 @@ extern crate clap;
5
5
extern crate log;
6
6
extern crate env_logger;
7
7
extern crate time;
8
+ extern crate rustwide;
8
9
9
10
10
11
use std:: env;
11
12
use std:: path:: PathBuf ;
12
13
13
14
use clap:: { Arg , App , SubCommand } ;
14
- use cratesfyi:: { DocBuilder , DocBuilderOptions , db} ;
15
- use cratesfyi:: utils:: { build_doc , add_crate_to_queue} ;
15
+ use cratesfyi:: { DocBuilder , RustwideBuilder , DocBuilderOptions , db} ;
16
+ use cratesfyi:: utils:: add_crate_to_queue;
16
17
use cratesfyi:: start_web_server;
17
18
use cratesfyi:: db:: { add_path_into_database, connect_db} ;
18
19
@@ -23,20 +24,6 @@ pub fn main() {
23
24
let matches = App :: new ( "cratesfyi" )
24
25
. version ( cratesfyi:: BUILD_VERSION )
25
26
. about ( env ! ( "CARGO_PKG_DESCRIPTION" ) )
26
- . subcommand ( SubCommand :: with_name ( "doc" )
27
- . about ( "Builds documentation of a crate" )
28
- . arg ( Arg :: with_name ( "CRATE_NAME" )
29
- . index ( 1 )
30
- . required ( true )
31
- . help ( "Crate name" ) )
32
- . arg ( Arg :: with_name ( "CRATE_VERSION" )
33
- . index ( 2 )
34
- . required ( false )
35
- . help ( "Crate version" ) )
36
- . arg ( Arg :: with_name ( "TARGET" )
37
- . index ( 3 )
38
- . required ( false )
39
- . help ( "The target platform to compile for" ) ) )
40
27
. subcommand ( SubCommand :: with_name ( "build" )
41
28
. about ( "Builds documentation in a chroot environment" )
42
29
. arg ( Arg :: with_name ( "PREFIX" )
@@ -48,21 +35,6 @@ pub fn main() {
48
35
. long ( "destination" )
49
36
. help ( "Sets destination path" )
50
37
. takes_value ( true ) )
51
- . arg ( Arg :: with_name ( "CHROOT_PATH" )
52
- . short ( "c" )
53
- . long ( "chroot-path" )
54
- . help ( "Sets chroot path" )
55
- . takes_value ( true ) )
56
- . arg ( Arg :: with_name ( "CHROOT_USER" )
57
- . short ( "u" )
58
- . long ( "chroot-user" )
59
- . help ( "Sets chroot user name" )
60
- . takes_value ( true ) )
61
- . arg ( Arg :: with_name ( "CONTAINER_NAME" )
62
- . short ( "n" )
63
- . long ( "container-name" )
64
- . help ( "Sets name of the container" )
65
- . takes_value ( true ) )
66
38
. arg ( Arg :: with_name ( "CRATES_IO_INDEX_PATH" )
67
39
. long ( "crates-io-index-path" )
68
40
. help ( "Sets crates.io-index path" )
@@ -152,15 +124,7 @@ pub fn main() {
152
124
153
125
154
126
155
- // doc subcommand
156
- if let Some ( matches) = matches. subcommand_matches ( "doc" ) {
157
- let name = matches. value_of ( "CRATE_NAME" ) . unwrap ( ) ;
158
- let version = matches. value_of ( "CRATE_VERSION" ) ;
159
- let target = matches. value_of ( "TARGET" ) ;
160
- if let Err ( e) = build_doc ( name, version, target) {
161
- panic ! ( "{:#?}" , e) ;
162
- }
163
- } else if let Some ( matches) = matches. subcommand_matches ( "build" ) {
127
+ if let Some ( matches) = matches. subcommand_matches ( "build" ) {
164
128
let docbuilder_opts = {
165
129
let mut docbuilder_opts = if let Some ( prefix) = matches. value_of ( "PREFIX" ) {
166
130
DocBuilderOptions :: from_prefix ( PathBuf :: from ( prefix) )
@@ -175,18 +139,6 @@ pub fn main() {
175
139
docbuilder_opts. destination = PathBuf :: from ( destination) ;
176
140
}
177
141
178
- if let Some ( chroot_path) = matches. value_of ( "CHROOT_PATH" ) {
179
- docbuilder_opts. chroot_path = PathBuf :: from ( chroot_path) ;
180
- }
181
-
182
- if let Some ( chroot_user) = matches. value_of ( "CHROOT_USER" ) {
183
- docbuilder_opts. chroot_user = chroot_user. to_string ( ) ;
184
- }
185
-
186
- if let Some ( container_name) = matches. value_of ( "CONTAINER_NAME" ) {
187
- docbuilder_opts. container_name = container_name. to_string ( ) ;
188
- }
189
-
190
142
if let Some ( crates_io_index_path) = matches. value_of ( "CRATES_IO_INDEX_PATH" ) {
191
143
docbuilder_opts. crates_io_index_path = PathBuf :: from ( crates_io_index_path) ;
192
144
}
@@ -204,16 +156,19 @@ pub fn main() {
204
156
205
157
if let Some ( _) = matches. subcommand_matches ( "world" ) {
206
158
docbuilder. load_cache ( ) . expect ( "Failed to load cache" ) ;
207
- docbuilder. build_world ( ) . expect ( "Failed to build world" ) ;
159
+ let mut builder = RustwideBuilder :: init ( ) . unwrap ( ) ;
160
+ builder. build_world ( & mut docbuilder) . expect ( "Failed to build world" ) ;
208
161
docbuilder. save_cache ( ) . expect ( "Failed to save cache" ) ;
209
162
} else if let Some ( matches) = matches. subcommand_matches ( "crate" ) {
210
163
docbuilder. load_cache ( ) . expect ( "Failed to load cache" ) ;
211
- docbuilder. build_package ( matches. value_of ( "CRATE_NAME" ) . unwrap ( ) ,
212
- matches. value_of ( "CRATE_VERSION" ) . unwrap ( ) )
164
+ let mut builder = RustwideBuilder :: init ( ) . unwrap ( ) ;
165
+ builder. build_package ( & mut docbuilder, matches. value_of ( "CRATE_NAME" ) . unwrap ( ) ,
166
+ matches. value_of ( "CRATE_VERSION" ) . unwrap ( ) )
213
167
. expect ( "Building documentation failed" ) ;
214
168
docbuilder. save_cache ( ) . expect ( "Failed to save cache" ) ;
215
169
} else if let Some ( _) = matches. subcommand_matches ( "add-essential-files" ) {
216
- docbuilder. add_essential_files ( ) . expect ( "Failed to add essential files" ) ;
170
+ let builder = RustwideBuilder :: init ( ) . unwrap ( ) ;
171
+ builder. add_essential_files ( ) . expect ( "failed to add essential files" ) ;
217
172
} else if let Some ( _) = matches. subcommand_matches ( "lock" ) {
218
173
docbuilder. lock ( ) . expect ( "Failed to lock" ) ;
219
174
} else if let Some ( _) = matches. subcommand_matches ( "unlock" ) {
@@ -287,5 +242,6 @@ fn logger_init() {
287
242
record. args( ) )
288
243
} ) ;
289
244
builder. parse ( & env:: var ( "RUST_LOG" ) . unwrap_or ( "cratesfyi=info" . to_owned ( ) ) ) ;
290
- builder. init ( ) ;
245
+
246
+ rustwide:: logging:: init_with ( builder. build ( ) ) ;
291
247
}
0 commit comments