@@ -14,6 +14,7 @@ use std::path::PathBuf;
14
14
use clap:: { Arg , App , SubCommand } ;
15
15
use cratesfyi:: { DocBuilder , DocBuilderOptions , db} ;
16
16
use cratesfyi:: utils:: build_doc;
17
+ use cratesfyi:: db:: add_path_into_database;
17
18
18
19
19
20
pub fn main ( ) {
@@ -87,9 +88,20 @@ pub fn main() {
87
88
. about ( "Database operations" )
88
89
. subcommand ( SubCommand :: with_name ( "init" )
89
90
. about ( "Initialize database. Currently \
90
- only creates tables in database.") )
91
+ only creates tables in database.") )
91
92
. subcommand ( SubCommand :: with_name ( "update-github-fields" )
92
- . about ( "Updates github stats for crates." ) ) )
93
+ . about ( "Updates github stats for crates." ) )
94
+ . subcommand ( SubCommand :: with_name ( "add-directory" )
95
+ . about ( "Adds a directory into database" )
96
+ . arg ( Arg :: with_name ( "DIRECTORY" )
97
+ . index ( 1 )
98
+ . required ( true )
99
+ . help ( "Path of file or \
100
+ directory") )
101
+ . arg ( Arg :: with_name ( "PREFIX" )
102
+ . index ( 2 )
103
+ . help ( "Prefix of files in \
104
+ database") ) ) )
93
105
. get_matches ( ) ;
94
106
95
107
@@ -161,6 +173,11 @@ pub fn main() {
161
173
}
162
174
} else if let Some ( _) = matches. subcommand_matches ( "update-github-fields" ) {
163
175
cratesfyi:: utils:: github_updater ( ) . expect ( "Failed to update github fields" ) ;
176
+ } else if let Some ( matches) = matches. subcommand_matches ( "add-directory" ) {
177
+ add_path_into_database ( & db:: connect_db ( ) . unwrap ( ) ,
178
+ matches. value_of ( "PREFIX" ) . unwrap_or ( "" ) ,
179
+ matches. value_of ( "DIRECTORY" ) . unwrap ( ) )
180
+ . unwrap ( ) ;
164
181
}
165
182
} else {
166
183
println ! ( "{}" , matches. usage( ) ) ;
0 commit comments