@@ -11,7 +11,7 @@ extern crate rustwide;
11
11
use std:: env;
12
12
use std:: path:: { Path , PathBuf } ;
13
13
14
- use clap:: { Arg , App , SubCommand } ;
14
+ use clap:: { Arg , App , AppSettings , SubCommand } ;
15
15
use cratesfyi:: { DocBuilder , RustwideBuilder , DocBuilderOptions , db} ;
16
16
use cratesfyi:: utils:: add_crate_to_queue;
17
17
use cratesfyi:: start_web_server;
@@ -24,8 +24,10 @@ pub fn main() {
24
24
let matches = App :: new ( "cratesfyi" )
25
25
. version ( cratesfyi:: BUILD_VERSION )
26
26
. about ( env ! ( "CARGO_PKG_DESCRIPTION" ) )
27
+ . setting ( AppSettings :: ArgRequiredElseHelp )
27
28
. subcommand ( SubCommand :: with_name ( "build" )
28
29
. about ( "Builds documentation in a chroot environment" )
30
+ . setting ( AppSettings :: ArgRequiredElseHelp )
29
31
. arg ( Arg :: with_name ( "PREFIX" )
30
32
. short ( "P" )
31
33
. long ( "prefix" )
@@ -89,6 +91,7 @@ pub fn main() {
89
91
. help ( "run the server in the foreground instead of detaching a child" ) ) )
90
92
. subcommand ( SubCommand :: with_name ( "database" )
91
93
. about ( "Database operations" )
94
+ . setting ( AppSettings :: ArgRequiredElseHelp )
92
95
. subcommand ( SubCommand :: with_name ( "move-to-s3" ) )
93
96
. subcommand ( SubCommand :: with_name ( "migrate" )
94
97
. about ( "Run database migrations" )
@@ -115,6 +118,7 @@ pub fn main() {
115
118
. help ( "Name of the crate to delete" ) ) ) )
116
119
. subcommand ( SubCommand :: with_name ( "queue" )
117
120
. about ( "Interactions with the build queue" )
121
+ . setting ( AppSettings :: ArgRequiredElseHelp )
118
122
. subcommand ( SubCommand :: with_name ( "add" )
119
123
. about ( "Add a crate to the build queue" )
120
124
. arg ( Arg :: with_name ( "CRATE_NAME" )
@@ -231,12 +235,15 @@ pub fn main() {
231
235
let conn = db:: connect_db ( ) . expect ( "failed to connect to the database" ) ;
232
236
db:: delete_crate ( & conn, & name) . expect ( "failed to delete the crate" ) ;
233
237
}
238
+
234
239
} else if let Some ( matches) = matches. subcommand_matches ( "start-web-server" ) {
235
240
start_web_server ( Some ( matches. value_of ( "SOCKET_ADDR" ) . unwrap_or ( "0.0.0.0:3000" ) ) ) ;
241
+
236
242
} else if let Some ( _) = matches. subcommand_matches ( "daemon" ) {
237
243
let foreground = matches. subcommand_matches ( "daemon" )
238
244
. map_or ( false , |opts| opts. is_present ( "FOREGROUND" ) ) ;
239
245
cratesfyi:: utils:: start_daemon ( !foreground) ;
246
+
240
247
} else if let Some ( matches) = matches. subcommand_matches ( "queue" ) {
241
248
if let Some ( matches) = matches. subcommand_matches ( "add" ) {
242
249
let priority = matches. value_of ( "BUILD_PRIORITY" ) . unwrap_or ( "5" ) ;
@@ -248,8 +255,6 @@ pub fn main() {
248
255
matches. value_of ( "CRATE_VERSION" ) . unwrap ( ) ,
249
256
priority) . expect ( "Could not add crate to queue" ) ;
250
257
}
251
- } else {
252
- println ! ( "{}" , matches. usage( ) ) ;
253
258
}
254
259
}
255
260
0 commit comments