pub fn write_changelog_to<P: AsRef<Path>>(&self, cl: P) -> WriterResult {
        debugln!("Writing changelog to file: {:?}", cl.as_ref());
        let mut contents = String::with_capacity(256);
        if let Some(ref infile) = self.infile {
            debugln!("infile set to: {:?}", infile);
            File::open(infile).map(|mut f| f.read_to_string(&mut contents).ok()).ok();
        } else {
            debugln!("infile not set, trying the outfile");
            File::open(cl.as_ref()).map(|mut f| f.read_to_string(&mut contents).ok()).ok();
        }
        contents.shrink_to_fit();

        if let Ok(mut file) = File::create(cl.as_ref()) {
            {
                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(..) = write!(&mut file, "\n\n\n") {
                return Err(Error::WriteErr);
            }

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

        Ok(())
    }
/// Writes the changelog to a specified file, and prepends new commits if file exists, or
/// creates the file if it doesn't.
///
/// # Example
///
/// ```no_run
/// # use clog::Clog;
/// let mut clog = Clog::new().unwrap_or_else(|e| e.exit());
///
/// clog.write_changelog_to("/myproject/new_changelog.md").unwrap_or_else(|e| {
///     // Prints the error and exits appropriately
///     e.exit();
/// });
/// ```
Writes the changelog to a specified file, and prepends new commits if file exists, or
creates the file if it doesn't.
Writes the changelog to a specified file and prepends new commits if file exists or creates the file if it doesn ' t .
pub fn write_changelog_to<P: AsRef<Path>>(&self, cl: P) -> WriterResult {
        debugln!("Writing changelog to file: {:?}", cl.as_ref());
        let mut contents = String::with_capacity(256);
        if let Some(ref infile) = self.infile {
            debugln!("infile set to: {:?}", infile);
            File::open(infile).map(|mut f| f.read_to_string(&mut contents).ok()).ok();
        } else {
            debugln!("infile not set, trying the outfile");
            File::open(cl.as_ref()).map(|mut f| f.read_to_string(&mut contents).ok()).ok();
        }
        contents.shrink_to_fit();
        if let Ok(mut file) = File::create(cl.as_ref()) {
            {
                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(..) = write!(&mut file, "\n\n\n") {
                return Err(Error::WriteErr);
            }
            if let Err(..) = file.write(contents.as_bytes()) {
                return Err(Error::WriteErr);
            }
        } else {
            return Err(Error::CreateFileErr);
        }
        Ok(())
    }
pub fn write_changelog_to < P : AsRef < Path > > ( & self , cl : P ) -> WriterResult { debugln ! ( " " cl as_ref ( ) ) ; let mut contents = String :: with_capacity ( 256 ) ; if let Some ( ref infile ) = self . infile { debugln ! ( " " infile ) ; File :: open ( infile ) . map ( | mut f | f . read_to_string ( & mut contents ) . ok ( ) ) . ok ( ) ; } else { debugln ! ( " " ) ; File :: open ( cl . as_ref ( ) ) . map ( | mut f | f . read_to_string ( & mut contents ) . ok ( ) ) . ok ( ) ; } contents . shrink_to_fit ( ) ; if let Ok ( mut file ) = File :: create ( cl . as_ref ( ) ) { { 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 ( .. ) = write ! ( mut file " \n \n \n " ) { return Err ( Error :: WriteErr ) ; } if let Err ( .. ) = file . write ( contents . as_bytes ( ) ) { return Err ( Error :: WriteErr ) ; } } else { return Err ( Error :: CreateFileErr ) ; } Ok ( ( ) ) }
Writes the changelog to a specified file, and prepends new commits if file exists, or
creates the file if it doesn't.
Writes the changelog to a specified file and prepends new commits if file exists or creates the file if it doesn ' t .
&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_to("/myproject/new_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_to ( " / myproject / new_changelog . md " ) . unwrap_or_else ( |e| { Prints the error and exits appropriately e . exit () ; } ) ; ` ` `