reworked the light novel menue to make it more cohesive as well as did error handeling in ln/search.rs

This commit is contained in:
Zastian Pretorius
2022-07-11 23:56:58 +01:00
parent 619b8c7f59
commit 36ac04079c
2 changed files with 18 additions and 15 deletions

View File

@@ -29,13 +29,9 @@ pub fn search_ln() -> String {
}
count += 1;
});
println!("(n)\t{}", "Search another title".red());
let mut ln_number = String::new();
std::io::stdin()
.read_line(&mut ln_number)
.expect("Failed to read line");
ln_number = ln_number.trim().to_string();
if ln_number != "n" {
println!("(s)\t{}", "Search another title".green());
let ln_number = string_input("Enter an option: ");
if ln_number != "s" && ln_number.parse::<usize>().is_ok() {
let ln_number = ln_number.trim().to_string();
let ln_number = ln_number.parse::<usize>().unwrap();
let ln_url = &ln_urls[ln_number];
@@ -43,6 +39,8 @@ pub fn search_ln() -> String {
_is_n = true;
print!("\x1B[2J\x1B[1;1H");
return ln_url;
} else {
print!("invalid input");
}
print!("\x1B[2J\x1B[1;1H");
}