diff options
author | Andrew Gallant <jamslam@gmail.com> | 2015-01-23 17:20:34 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2015-01-23 17:20:34 -0500 |
commit | 02efa269801f61103f26d5e775b72d0b56cee6a9 (patch) | |
tree | 8baed7af75725b9815356cf3e9b7f117dc14e028 /src/main.rs | |
parent | 2531a91494f08a30e5f24f8860d0b63bcb0bc1e1 (diff) |
rustup
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 3739b7a..2b2b612 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ extern crate tabwriter; use std::borrow::ToOwned; use std::error::FromError; +use std::fmt; use std::io; use std::os; @@ -126,7 +127,7 @@ Please choose one of the following commands:", } } -#[derive(RustcDecodable, Show)] +#[derive(Debug, RustcDecodable)] enum Command { Cat, Count, @@ -176,7 +177,7 @@ impl Command { type CliResult<T> = Result<T, CliError>; -#[derive(Show)] +#[derive(Debug)] enum CliError { Flag(docopt::Error), Csv(csv::Error), @@ -184,6 +185,17 @@ enum CliError { Other(String), } +impl fmt::Display for CliError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + CliError::Flag(ref e) => { e.fmt(f) } + CliError::Csv(ref e) => { e.fmt(f) } + CliError::Io(ref e) => { e.fmt(f) } + CliError::Other(ref s) => { f.write_str(&**s) } + } + } +} + impl FromError<docopt::Error> for CliError { fn from_error(err: docopt::Error) -> CliError { CliError::Flag(err) |