Skip to content

Commit f3828e7

Browse files
KixironJoshua Nelson
authored andcommitted
Fixed cli args
1 parent 6e89df9 commit f3828e7

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/bin/cratesfyi.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -318,27 +318,30 @@ pub fn main() {
318318
priority,
319319
)
320320
.expect("Could not add crate to queue");
321-
} else if let Some(matches) = matches.subcommand_matches("set") {
322-
let pattern = matches
323-
.value_of("PATTERN")
324-
.expect("You must give a pattern to match with");
325-
let priority = clap::value_t!(matches.value_of("PRIORITY"), i32)
326-
.expect("You must give a priority for a crate");
327-
let conn = connect_db().expect("Could not connect to the database");
321+
} else if let Some(matches) = matches.subcommand_matches("default-priority") {
322+
if let Some(matches) = matches.subcommand_matches("set") {
323+
let pattern = matches
324+
.value_of("PATTERN")
325+
.expect("You must give a pattern to match with");
326+
let priority = clap::value_t!(matches.value_of("PRIORITY"), i32)
327+
.expect("You must give a priority for a crate");
328+
let conn = connect_db().expect("Could not connect to the database");
328329

329-
set_crate_priority(&conn, pattern, priority).expect("Could not set pattern's priority");
330-
} else if let Some(matches) = matches.subcommand_matches("remove") {
331-
let pattern = matches
332-
.value_of("PATTERN")
333-
.expect("You must give a pattern to remove");
334-
let conn = connect_db().expect("Could not connect to the database");
330+
set_crate_priority(&conn, pattern, priority)
331+
.expect("Could not set pattern's priority");
332+
} else if let Some(matches) = matches.subcommand_matches("remove") {
333+
let pattern = matches
334+
.value_of("PATTERN")
335+
.expect("You must give a pattern to remove");
336+
let conn = connect_db().expect("Could not connect to the database");
335337

336-
if let Some(priority) =
337-
remove_crate_priority(&conn, pattern).expect("Could not remove pattern's priority")
338-
{
339-
println!("Removed pattern with priority {}", priority);
340-
} else {
341-
println!("Pattern did not exist and so was not removed");
338+
if let Some(priority) = remove_crate_priority(&conn, pattern)
339+
.expect("Could not remove pattern's priority")
340+
{
341+
println!("Removed pattern with priority {}", priority);
342+
} else {
343+
println!("Pattern did not exist and so was not removed");
344+
}
342345
}
343346
}
344347
}

0 commit comments

Comments
 (0)