diff options
author | Ben S <ogham@bsago.me> | 2015-03-02 14:54:38 +0000 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2015-03-02 14:54:38 +0000 |
commit | 67f60e614bafc5d1584c931a81ea342cae5f88ed (patch) | |
tree | 0bc8424020c055bb7ed3e07415fa4c56d26c5b16 | |
parent | 369a42135992d8175b5f00383005c0a40bc0d0a8 (diff) |
Add --version command (and bump version)v0.2.0
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/options.rs | 9 |
3 files changed, 11 insertions, 2 deletions
@@ -1,6 +1,6 @@ [root] name = "exa" -version = "0.1.0" +version = "0.2.0" dependencies = [ "ansi_term 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1,6 +1,6 @@ [package] name = "exa" -version = "0.1.0" +version = "0.2.0" authors = [ "ogham@bsago.me" ] [[bin]] diff --git a/src/options.rs b/src/options.rs index 40a7b4b..ec015f9 100644 --- a/src/options.rs +++ b/src/options.rs @@ -68,6 +68,8 @@ impl Options { opts.optflag("u", "accessed", "display timestamp of last access for a file"); opts.optflag("U", "created", "display timestamp of creation for a file"); opts.optflag("x", "across", "sort multi-column view entries across"); + + opts.optflag("", "version", "display version of exa"); opts.optflag("?", "help", "show list of command-line options"); if xattr::feature_implemented() { @@ -82,6 +84,9 @@ impl Options { if matches.opt_present("help") { return Err(Misfire::Help(opts.usage("Usage:\n exa [options] [files...]"))); } + else if matches.opt_present("version") { + return Err(Misfire::Version); + } let sort_field = match matches.opt_str("sort") { Some(word) => try!(SortField::from_word(word)), @@ -191,6 +196,9 @@ pub enum Misfire { /// this enum isn't named Error! Help(String), + /// The user wanted the version number. + Version, + /// Two options were given that conflict with one another. Conflict(&'static str, &'static str), @@ -219,6 +227,7 @@ impl fmt::Display for Misfire { match *self { InvalidOptions(ref e) => write!(f, "{}", e), Help(ref text) => write!(f, "{}", text), + Version => write!(f, "exa {}", env!("CARGO_PKG_VERSION")), Conflict(a, b) => write!(f, "Option --{} conflicts with option {}.", a, b), Useless(a, false, b) => write!(f, "Option --{} is useless without option --{}.", a, b), Useless(a, true, b) => write!(f, "Option --{} is useless given option --{}.", a, b), |