jockey 0.3.0

Custom command-line parsers that practically write themselves
Documentation
use std::error;
use std::fmt;

use std::error::Error as StdError;

/// Error type for this crate.
#[derive(Debug, Clone, PartialEq)]
pub enum Error {
    UnknownOption(String),
    UnexpectedEnd,
}

impl error::Error for Error {
    fn description(&self) -> &str {
        match self {
            Error::UnknownOption(_) => "Unknown option",
            Error::UnexpectedEnd => "Unexpected end of arguments vector",
        }
    }
    
    fn cause(&self) -> Option<&error::Error> {
        None
    }
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Error::UnknownOption(which) => write!(f, "{}: {}", self.description(), which),
            _ => write!(f, "{}", self.description()),
        }
    }
}

/// Result type for this crate.
pub type Result<T> = std::result::Result<T, Error>;