pub fn search_notes(
        &mut self,
        pattern: &String,
        regex: bool,
        limit: usize,
        condensed: bool,
        json: bool,
        datesort: bool,
        reverse: bool,
        search_body: bool,
        no_status: bool,
        started_status: bool,
        urgent_status:bool
    ) -> Result<(), ThecaError> {
        let notes: Vec<ThecaItem> = match regex {
            true => {
                let re = match Regex::new(&pattern[..]) {
                    Ok(r) => r,
                    Err(e) => specific_fail!(
                        format!("regex error: {}.", e.msg)
                    )
                };
                self.notes.iter().filter(|n| match search_body {
                    true => re.is_match(&*n.body),
                    false => re.is_match(&*n.title)
                }).map(|n| n.clone()).collect()
            },
            false => {
                self.notes.iter().filter(|n| match search_body {
                    true => n.body.contains(&pattern[..]),
                    false => n.title.contains(&pattern[..])
                }).map(|n| n.clone()).collect()
            }
        };
        if notes.len() > 0 {
            try!(sorted_print(
                &mut notes.clone(),
                limit,
                condensed,
                json,
                datesort,
                reverse,
                search_body,
                no_status,
                started_status,
                urgent_status
            ));
        } else {
            match json {
                true => println!("[]"),
                false => println!("nothing found")
            }
        }
        Ok(())
    }
/// print notes search for in the profile
print notes search for in the profile
print notes search for in the profile
pub fn search_notes(
        &mut self,
        pattern: &String,
        regex: bool,
        limit: usize,
        condensed: bool,
        json: bool,
        datesort: bool,
        reverse: bool,
        search_body: bool,
        no_status: bool,
        started_status: bool,
        urgent_status:bool
    ) -> Result<(), ThecaError> {
        let notes: Vec<ThecaItem> = match regex {
            true => {
                let re = match Regex::new(&pattern[..]) {
                    Ok(r) => r,
                    Err(e) => specific_fail!(
                        format!("regex error: {}.", e.msg)
                    )
                };
                self.notes.iter().filter(|n| match search_body {
                    true => re.is_match(&*n.body),
                    false => re.is_match(&*n.title)
                }).map(|n| n.clone()).collect()
            },
            false => {
                self.notes.iter().filter(|n| match search_body {
                    true => n.body.contains(&pattern[..]),
                    false => n.title.contains(&pattern[..])
                }).map(|n| n.clone()).collect()
            }
        };
        if notes.len() > 0 {
            try!(sorted_print(
                &mut notes.clone(),
                limit,
                condensed,
                json,
                datesort,
                reverse,
                search_body,
                no_status,
                started_status,
                urgent_status
            ));
        } else {
            match json {
                true => println!("[]"),
                false => println!("nothing found")
            }
        }
        Ok(())
    }
pub fn search_notes ( & mut self , pattern : & String , regex : bool , limit : usize , condensed : bool , json : bool , datesort : bool , reverse : bool , search_body : bool , no_status : bool , started_status : bool , urgent_status : bool ) -> Result < ( ) , ThecaError > { let notes : Vec < ThecaItem > = match regex { true => { let re = match Regex :: new ( & pattern [ .. ] ) { Ok ( r ) => r , Err ( e ) => specific_fail ! ( format ( " " e msg ) ) } ; self . notes . iter ( ) . filter ( | n | match search_body { true => re . is_match ( & * n . body ) , false => re . is_match ( & * n . title ) } ) . map ( | n | n . clone ( ) ) . collect ( ) } , false => { self . notes . iter ( ) . filter ( | n | match search_body { true => n . body . contains ( & pattern [ .. ] ) , false => n . title . contains ( & pattern [ .. ] ) } ) . map ( | n | n . clone ( ) ) . collect ( ) } } ; if notes . len ( ) > 0 { try ! ( sorted_print ( mut notes clone ( ) limit condensed json datesort reverse search_body no_status started_status urgent_status ) ) ; } else { match json { true => println ! ( " " ) , false => println ! ( " " ) } } Ok ( ( ) ) }
print notes search for in the profile
print notes search for in the profile
&mut self
pattern
&String
regex
bool
limit
usize
condensed
bool
json
bool
datesort
bool
reverse
bool
search_body
bool
no_status
bool
started_status
bool
urgent_status
bool
&mut self
pattern
&String
regex
bool
limit
usize
condensed
bool
json
bool
datesort
bool
reverse
bool
search_body
bool
no_status
bool
started_status
bool
urgent_status
bool