Skip to content

Commit c7b210b

Browse files
committed
Add add-directory subcommand to database
1 parent 764d799 commit c7b210b

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/bin/cratesfyi.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::path::PathBuf;
1414
use clap::{Arg, App, SubCommand};
1515
use cratesfyi::{DocBuilder, DocBuilderOptions, db};
1616
use cratesfyi::utils::build_doc;
17+
use cratesfyi::db::add_path_into_database;
1718

1819

1920
pub fn main() {
@@ -87,9 +88,20 @@ pub fn main() {
8788
.about("Database operations")
8889
.subcommand(SubCommand::with_name("init")
8990
.about("Initialize database. Currently \
90-
only creates tables in database."))
91+
only creates tables in database."))
9192
.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"))))
93105
.get_matches();
94106

95107

@@ -161,6 +173,11 @@ pub fn main() {
161173
}
162174
} else if let Some(_) = matches.subcommand_matches("update-github-fields") {
163175
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();
164181
}
165182
} else {
166183
println!("{}", matches.usage());

0 commit comments

Comments
 (0)