1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
mod git_stash;
mod bm;
use clap::Clap;
use std::error::Error;

#[derive(Clap)]
#[clap(version = env!("CARGO_PKG_VERSION"))]
pub struct Arg {
    /// string to search
    string: String,
}

pub fn run(arg: Arg) -> Result<(), Box<dyn Error>> {
    let executor = git_stash::GitStashExecutor::new();
    let mut stashes = git_stash::get_stashes(executor)?;

    stashes.sort();
    for stash in stashes {
        match bm::search(&stash.patch_show_output, &arg.string) {
            Some(_) => println!("{}", stash),
            None => continue,
        }
    }

    Ok(())
}