Skip to content

Commit

Permalink
Get rid of returns from entry()
Browse files Browse the repository at this point in the history
I just felt like doing it while browsing the code.
  • Loading branch information
rexim committed Jan 30, 2023
1 parent b7585d8 commit c3d96c9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ fn entry() -> Result<(), ()> {

let mut tf_index = TermFreqIndex::new();
tf_index_of_folder(Path::new(&dir_path), &mut tf_index)?;
save_tf_index(&tf_index, "index.json")?;

save_tf_index(&tf_index, "index.json")
},
"search" => {
let index_path = args.next().ok_or_else(|| {
Expand All @@ -148,6 +149,8 @@ fn entry() -> Result<(), ()> {
for (path, rank) in search_query(&tf_index, &prompt).iter().take(20) {
println!("{path} {rank}", path = path.display());
}

Ok(())
}
"serve" => {
let index_path = args.next().ok_or_else(|| {
Expand All @@ -165,16 +168,14 @@ fn entry() -> Result<(), ()> {

let address = args.next().unwrap_or("127.0.0.1:6969".to_string());

return server::start(&address, &tf_index)
server::start(&address, &tf_index)
}
_ => {
usage(&program);
eprintln!("ERROR: unknown subcommand {subcommand}");
return Err(());
Err(())
}
}

Ok(())
}

fn main() -> ExitCode {
Expand Down

0 comments on commit c3d96c9

Please sign in to comment.