Skip to content

Commit

Permalink
Add --version command (and bump version)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogham committed Mar 2, 2015
1 parent 369a421 commit 67f60e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "exa"
version = "0.1.0"
version = "0.2.0"
authors = [ "[email protected]" ]

[[bin]]
Expand Down
9 changes: 9 additions & 0 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)),
Expand Down Expand Up @@ -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),

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 67f60e6

Please sign in to comment.