pub fn write_changelog_from<P: AsRef<Path>>(&self, cl: P) -> WriterResult {
        debugln!("Writing changelog from file: {:?}", cl.as_ref());
        let mut contents = String::with_capacity(256);
        File::open(cl.as_ref()).map(|mut f| f.read_to_string(&mut contents).ok()).ok();
        contents.shrink_to_fit();

        if let Some(ref ofile) = self.outfile {
            debugln!("outfile set to: {:?}", ofile);
            if let Ok(mut file) = File::create(ofile) {
                {
                    match self.out_format {
                        ChangelogFormat::Markdown => {
                            let mut writer = MarkdownWriter::new(&mut file);
                            try!(self.write_changelog_with(&mut writer));
                        }
                        ChangelogFormat::Json => {
                            let mut writer = JsonWriter::new(&mut file);
                            try!(self.write_changelog_with(&mut writer));
                        }
                    }
                }

                if let Err(..) = file.write(contents.as_bytes()) {
                    return Err(Error::WriteErr)
                }
            } else {
                return Err(Error::CreateFileErr)
            }
        } else {
            debugln!("outfile not set, using stdout");
            let out = stdout();
            let mut out_buf = BufWriter::new(out.lock());
            {
                match self.out_format {
                    ChangelogFormat::Markdown => {
                        let mut writer = MarkdownWriter::new(&mut out_buf);
                        try!(self.write_changelog_with(&mut writer));
                    }
                    ChangelogFormat::Json => {
                        let mut writer = JsonWriter::new(&mut out_buf);
                        try!(self.write_changelog_with(&mut writer));
                    }
                }
            }
            if let Err(..) = write!(&mut out_buf, "\n\n\n") {
                return Err(Error::WriteErr);
            }

            if let Err(..) = out_buf.write(contents.as_bytes()) {
                return Err(Error::WriteErr);
            }
        }

        Ok(())
    }
/// Writes the changelog from a specified input file, and appends new commits
///
/// # Example
///
/// ```no_run
/// # use clog::Clog;
/// let mut clog = Clog::new().unwrap_or_else(|e| e.exit());
///
/// clog.write_changelog_from("/myproject/new_old_changelog.md").unwrap_or_else(|e| {
///     // Prints the error and exits appropriately
///     e.exit();
/// });
/// ```
Writes the changelog from a specified input file, and appends new commits
Writes the changelog from a specified input file and appends new commits
pub fn write_changelog_from<P: AsRef<Path>>(&self, cl: P) -> WriterResult {
        debugln!("Writing changelog from file: {:?}", cl.as_ref());
        let mut contents = String::with_capacity(256);
        File::open(cl.as_ref()).map(|mut f| f.read_to_string(&mut contents).ok()).ok();
        contents.shrink_to_fit();
        if let Some(ref ofile) = self.outfile {
            debugln!("outfile set to: {:?}", ofile);
            if let Ok(mut file) = File::create(ofile) {
                {
                    match self.out_format {
                        ChangelogFormat::Markdown => {
                            let mut writer = MarkdownWriter::new(&mut file);
                            try!(self.write_changelog_with(&mut writer));
                        }
                        ChangelogFormat::Json => {
                            let mut writer = JsonWriter::new(&mut file);
                            try!(self.write_changelog_with(&mut writer));
                        }
                    }
                }
                if let Err(..) = file.write(contents.as_bytes()) {
                    return Err(Error::WriteErr)
                }
            } else {
                return Err(Error::CreateFileErr)
            }
        } else {
            debugln!("outfile not set, using stdout");
            let out = stdout();
            let mut out_buf = BufWriter::new(out.lock());
            {
                match self.out_format {
                    ChangelogFormat::Markdown => {
                        let mut writer = MarkdownWriter::new(&mut out_buf);
                        try!(self.write_changelog_with(&mut writer));
                    }
                    ChangelogFormat::Json => {
                        let mut writer = JsonWriter::new(&mut out_buf);
                        try!(self.write_changelog_with(&mut writer));
                    }
                }
            }
            if let Err(..) = write!(&mut out_buf, "\n\n\n") {
                return Err(Error::WriteErr);
            }
            if let Err(..) = out_buf.write(contents.as_bytes()) {
                return Err(Error::WriteErr);
            }
        }
        Ok(())
    }
pub fn write_changelog_from < P : AsRef < Path > > ( & self , cl : P ) -> WriterResult { debugln ! ( " " cl as_ref ( ) ) ; let mut contents = String :: with_capacity ( 256 ) ; File :: open ( cl . as_ref ( ) ) . map ( | mut f | f . read_to_string ( & mut contents ) . ok ( ) ) . ok ( ) ; contents . shrink_to_fit ( ) ; if let Some ( ref ofile ) = self . outfile { debugln ! ( " " ofile ) ; if let Ok ( mut file ) = File :: create ( ofile ) { { match self . out_format { ChangelogFormat :: Markdown => { let mut writer = MarkdownWriter :: new ( & mut file ) ; try ! ( self write_changelog_with ( mut writer ) ) ; } ChangelogFormat :: Json => { let mut writer = JsonWriter :: new ( & mut file ) ; try ! ( self write_changelog_with ( mut writer ) ) ; } } } if let Err ( .. ) = file . write ( contents . as_bytes ( ) ) { return Err ( Error :: WriteErr ) } } else { return Err ( Error :: CreateFileErr ) } } else { debugln ! ( " " ) ; let out = stdout ( ) ; let mut out_buf = BufWriter :: new ( out . lock ( ) ) ; { match self . out_format { ChangelogFormat :: Markdown => { let mut writer = MarkdownWriter :: new ( & mut out_buf ) ; try ! ( self write_changelog_with ( mut writer ) ) ; } ChangelogFormat :: Json => { let mut writer = JsonWriter :: new ( & mut out_buf ) ; try ! ( self write_changelog_with ( mut writer ) ) ; } } } if let Err ( .. ) = write ! ( mut out_buf " \n \n \n " ) { return Err ( Error :: WriteErr ) ; } if let Err ( .. ) = out_buf . write ( contents . as_bytes ( ) ) { return Err ( Error :: WriteErr ) ; } } Ok ( ( ) ) }
Writes the changelog from a specified input file, and appends new commits
Writes the changelog from a specified input file and appends new commits
&self
cl
P
&self
cl
P
example
None
use clog::clog;
let mut clog = Clog::new().unwrap_or_else(|e| e.exit()).

clog.write_changelog_from("/myproject/new_old_changelog.md").unwrap_or_else(|e| {
Prints the error and exits appropriately
e.exit();
});
```
let mut clog = Clog :: new () . unwrap_or_else ( |e| e . exit () ) . clog . write_changelog_from ( " / myproject / new_old_changelog . md " ) . unwrap_or_else ( |e| { Prints the error and exits appropriately e . exit () ; } ) ; ` ` `