git-box 0.1.1

git-box executable implementation
Documentation
#[cfg(feature = "artifactory")]
use curl::ErrCode;
use docopt;
use git2;
#[cfg(feature = "ssh2")]
use ssh2::Error as Ssh2Error;
use std::error::Error;
use std::fmt;
use std::io;
use std::num::ParseIntError;
use std::string::FromUtf8Error;

use self::GitBoxError::*;

#[derive(Debug)]
/// An error thrown by the git-box process.
pub enum GitBoxError {
    #[cfg(feature = "artifactory")]
    /// Error thrown during curl operations.
    CURL(ErrCode),
    /// Error thrown parsing arguments.
    Docopt(docopt::Error),
    /// Error thrown during git operations.
    Git(git2::Error),
    /// Error thrown during I/O operations.
    IO(io::Error),
    /// Error thrown parsing an int.
    PARSEINT(ParseIntError),
    /// Error thrown parsing a string.
    PARSESTR(FromUtf8Error),
    #[cfg(feature = "ssh2")]
    /// Error thrown during ssh operations.
    SSH(Ssh2Error),
    /// Generic Error.
    Other(&'static str),
}

impl fmt::Display for GitBoxError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        writeln!(f, "test")
    }
}

impl Error for GitBoxError {
    fn description(&self) -> &str {
        match *self {
            #[cfg(feature = "artifactory")]
            CURL(_) => "CurlError",
            _ => "Other",
        }
    }

    fn cause(&self) -> Option<&Error> {
        match *self {
            #[cfg(feature = "artifactory")]
            CURL(ref e) => Some(e),
            _ => None,
        }
    }
}

#[cfg(feature = "artifactory")]
impl From<ErrCode> for GitBoxError {
    fn from(err: ErrCode) -> GitBoxError {
        CURL(err)
    }
}

impl From<docopt::Error> for GitBoxError {
    fn from(err: docopt::Error) -> GitBoxError {
        Docopt(err)
    }
}

impl From<git2::Error> for GitBoxError {
    fn from(err: git2::Error) -> GitBoxError {
        Git(err)
    }
}

impl From<io::Error> for GitBoxError {
    fn from(err: io::Error) -> GitBoxError {
        IO(err)
    }
}

#[cfg(feature = "ssh2")]
impl From<Ssh2Error> for GitBoxError {
    fn from(err: Ssh2Error) -> GitBoxError {
        SSH(err)
    }
}

impl From<ParseIntError> for GitBoxError {
    fn from(err: ParseIntError) -> GitBoxError {
        PARSEINT(err)
    }
}

impl From<FromUtf8Error> for GitBoxError {
    fn from(err: FromUtf8Error) -> GitBoxError {
        PARSESTR(err)
    }
}