use crate::storage::{Post, search_it};
use crate::tui;
use std::error::Error;
pub fn execute(needle: &str, haystack: &[Post]) -> Result<(), Box<dyn Error>> {
if haystack.is_empty() {
eprintln!("The database is empty. Add a command first with: memplace save 'command'");
return Ok(());
}
let matching = search_it(needle, haystack);
if matching.is_empty() {
println!("No results found for '{}'", needle);
return Ok(());
}
tui::check(&matching, needle)?;
Ok(())
}