diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index fc82739..8cb8466 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,10 +27,10 @@ fn main() { let input = args.get(2).unwrap(); let file = args.get(3).unwrap(); - let _ = Index::generate(input, file, |counter, nof| { + let _ = Index::generate(input, |counter, nof| { eprint!("\r\x1b[2K{} of {} files indexed ({}%)", counter, nof, (counter * 100) / nof); std::io::stdout().flush().ok(); - }); + }).save(file.to_string()); } else if cmd == "-s" { if args.len() < 4 { eprintln!("{} -s <indexfile> ...", args.get(0).unwrap()); @@ -42,11 +42,24 @@ fn main() { let search = v.join(" "); let searchvec = splitter::split_to_words(search); - let idx = Index::from_file(file.as_str()); + let idx = Index::from_file(file); let results = idx.search(searchvec); for result in results { println!("{}", result.path); } + } else if cmd == "-m" { + if args.len() != 5 { + eprintln!("{} -m <index1> <index2> <merged index>", args.get(0).unwrap()); + return; + } + + let index1 = args.get(2).unwrap().clone(); + let index2 = args.get(3).unwrap().clone(); + let merged = args.get(4).unwrap().clone(); + let _ = Index::merge( + Index::from_file(index1), + Index::from_file(index2) + ).save(merged); } } else { let _ = gui::run(); |