pub fn edit_note(
        &mut self,
        id: usize,
        title: &String,
        body: &Vec<String>,
        started: bool,
        urgent: bool,
        no_status: bool,
        use_stdin: bool,
        use_editor: bool,
        encrypted: bool,
        yes: bool
    ) -> Result<(), ThecaError> {
        // let id = args.arg_id[0];
        let item_pos: usize = match self.notes.iter().position(|n| n.id == id) {
            Some(i) => i,
            None => specific_fail!(format!("note {} doesn't exist", id))
        };
        if !title.is_empty() {
            match title.replace("\n", "") == "-" {
                true => match !use_stdin {
                    true => self.notes[item_pos].body = try!(
                        stdin().read_to_string()
                    ),
                    false => self.notes[item_pos].title = title.replace("\n", "")
                                                               .to_string()
                },
                false => self.notes[item_pos].title = title.replace("\n", "")
                                                           .to_string()
            }
            // change title
        }
        if started || urgent || no_status {
            // change status
            if started {
                self.notes[item_pos].status = STARTED.to_string();
            } else if urgent {
                self.notes[item_pos].status = URGENT.to_string();
            } else if no_status {
                self.notes[item_pos].status = NOSTATUS.to_string();
            }
        }

        if !body.is_empty() || use_editor || use_stdin {
            // change body
            self.notes[item_pos].body = match use_stdin {
                true => try!(stdin().read_to_string()),
                false => match use_editor {
                    true => {
                        match istty(STDOUT_FILENO) && istty(STDIN_FILENO) {
                            true => {
                                if encrypted && !yes {
                                    println!(
                                        "{0}\n\n{1}\n{2}\n\n{0}\n{3}\n",
                                        "## [WARNING] ##",
                                        "continuing will write the body of the decrypted note to a temporary",
                                        "file, increasing the possibilty it could be recovered later.",
                                        "Are you sure you want to continue?"
                                    );
                                    if !try!(get_yn_input()) {specific_fail_str!("ok bye ♥");}
                                }
                                let new_body = try!(
                                    drop_to_editor(&self.notes[item_pos].body)
                                );
                                match self.notes[item_pos].body != new_body {
                                    true => new_body,
                                    false => self.notes[item_pos].body.clone()
                                }     
                            },
                            false => self.notes[item_pos].body.clone()
                        }
                    },
                    false => body[0].clone()
                }
            };
        }

        // update last_touched
        self.notes[item_pos].last_touched = try!(strftime(DATEFMT, &now()));
        println!("edited note {}", self.notes[item_pos].id);
        Ok(())
    }
/// edit an item in the profile
edit an item in the profile
edit an item in the profile
pub fn edit_note(
        &mut self,
        id: usize,
        title: &String,
        body: &Vec<String>,
        started: bool,
        urgent: bool,
        no_status: bool,
        use_stdin: bool,
        use_editor: bool,
        encrypted: bool,
        yes: bool
    ) -> Result<(), ThecaError> {
        // let id = args.arg_id[0];
        let item_pos: usize = match self.notes.iter().position(|n| n.id == id) {
            Some(i) => i,
            None => specific_fail!(format!("note {} doesn't exist", id))
        };
        if !title.is_empty() {
            match title.replace("\n", "") == "-" {
                true => match !use_stdin {
                    true => self.notes[item_pos].body = try!(
                        stdin().read_to_string()
                    ),
                    false => self.notes[item_pos].title = title.replace("\n", "")
                                                               .to_string()
                },
                false => self.notes[item_pos].title = title.replace("\n", "")
                                                           .to_string()
            }
            // change title
        }
        if started || urgent || no_status {
            // change status
            if started {
                self.notes[item_pos].status = STARTED.to_string();
            } else if urgent {
                self.notes[item_pos].status = URGENT.to_string();
            } else if no_status {
                self.notes[item_pos].status = NOSTATUS.to_string();
            }
        }
        if !body.is_empty() || use_editor || use_stdin {
            // change body
            self.notes[item_pos].body = match use_stdin {
                true => try!(stdin().read_to_string()),
                false => match use_editor {
                    true => {
                        match istty(STDOUT_FILENO) && istty(STDIN_FILENO) {
                            true => {
                                if encrypted && !yes {
                                    println!(
                                        "{0}\n\n{1}\n{2}\n\n{0}\n{3}\n",
                                        "## [WARNING] ##",
                                        "continuing will write the body of the decrypted note to a temporary",
                                        "file, increasing the possibilty it could be recovered later.",
                                        "Are you sure you want to continue?"
                                    );
                                    if !try!(get_yn_input()) {specific_fail_str!("ok bye ♥");}
                                }
                                let new_body = try!(
                                    drop_to_editor(&self.notes[item_pos].body)
                                );
                                match self.notes[item_pos].body != new_body {
                                    true => new_body,
                                    false => self.notes[item_pos].body.clone()
                                }     
                            },
                            false => self.notes[item_pos].body.clone()
                        }
                    },
                    false => body[0].clone()
                }
            };
        }
        // update last_touched
        self.notes[item_pos].last_touched = try!(strftime(DATEFMT, &now()));
        println!("edited note {}", self.notes[item_pos].id);
        Ok(())
    }
pub fn edit_note ( & mut self , id : usize , title : & String , body : & Vec < String > , started : bool , urgent : bool , no_status : bool , use_stdin : bool , use_editor : bool , encrypted : bool , yes : bool ) -> Result < ( ) , ThecaError > { // let id = args.arg_id[0]; let item_pos : usize = match self . notes . iter ( ) . position ( | n | n . id == id ) { Some ( i ) => i , None => specific_fail ! ( format ( " " id ) ) } ; if ! title . is_empty ( ) { match title . replace ( " \n " , " " ) == " " { true => match ! use_stdin { true => self . notes [ item_pos ] . body = try ! ( stdin ( ) read_to_string ( ) ) , false => self . notes [ item_pos ] . title = title . replace ( " \n " , " " ) . to_string ( ) } , false => self . notes [ item_pos ] . title = title . replace ( " \n " , " " ) . to_string ( ) } // change title } if started || urgent || no_status { // change status if started { self . notes [ item_pos ] . status = STARTED . to_string ( ) ; } else if urgent { self . notes [ item_pos ] . status = URGENT . to_string ( ) ; } else if no_status { self . notes [ item_pos ] . status = NOSTATUS . to_string ( ) ; } } if ! body . is_empty ( ) || use_editor || use_stdin { // change body self . notes [ item_pos ] . body = match use_stdin { true => try ! ( stdin ( ) read_to_string ( ) ) , false => match use_editor { true => { match istty ( STDOUT_FILENO ) && istty ( STDIN_FILENO ) { true => { if encrypted && ! yes { println ! ( " \n \n \n \n \n \n \n " " " " " " " " " ) ; if ! try ! ( get_yn_input ( ) ) { specific_fail_str ! ( " ; } } let new_body = try ! ( drop_to_editor ( self notes [ item_pos ] body ) ) ; match self . notes [ item_pos ] . body != new_body { true => new_body , false => self . notes [ item_pos ] . body . clone ( ) } } , false => self . notes [ item_pos ] . body . clone ( ) } } , false => body [ 0 ] . clone ( ) } } ; } // update last_touched self . notes [ item_pos ] . last_touched = try ! ( strftime ( DATEFMT now ( ) ) ) ; println ! ( " " self notes [ item_pos ] id ) ; Ok ( ( ) ) }
edit an item in the profile
edit an item in the profile
&mut self
id
usize
title
&String
body
&Vec<String>
started
bool
urgent
bool
no_status
bool
use_stdin
bool
use_editor
bool
encrypted
bool
yes
bool
&mut self
id
usize
title
&String
body
&Vec<String>
started
bool
urgent
bool
no_status
bool
use_stdin
bool
use_editor
bool
encrypted
bool
yes
bool