Skip to content

Commit 67f60e6

Browse files
committed
Add --version command (and bump version)
1 parent 369a421 commit 67f60e6

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "exa"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = [ "ogham@bsago.me" ]
55

66
[[bin]]

src/options.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ impl Options {
6868
opts.optflag("u", "accessed", "display timestamp of last access for a file");
6969
opts.optflag("U", "created", "display timestamp of creation for a file");
7070
opts.optflag("x", "across", "sort multi-column view entries across");
71+
72+
opts.optflag("", "version", "display version of exa");
7173
opts.optflag("?", "help", "show list of command-line options");
7274

7375
if xattr::feature_implemented() {
@@ -82,6 +84,9 @@ impl Options {
8284
if matches.opt_present("help") {
8385
return Err(Misfire::Help(opts.usage("Usage:\n exa [options] [files...]")));
8486
}
87+
else if matches.opt_present("version") {
88+
return Err(Misfire::Version);
89+
}
8590

8691
let sort_field = match matches.opt_str("sort") {
8792
Some(word) => try!(SortField::from_word(word)),
@@ -191,6 +196,9 @@ pub enum Misfire {
191196
/// this enum isn't named Error!
192197
Help(String),
193198

199+
/// The user wanted the version number.
200+
Version,
201+
194202
/// Two options were given that conflict with one another.
195203
Conflict(&'static str, &'static str),
196204

@@ -219,6 +227,7 @@ impl fmt::Display for Misfire {
219227
match *self {
220228
InvalidOptions(ref e) => write!(f, "{}", e),
221229
Help(ref text) => write!(f, "{}", text),
230+
Version => write!(f, "exa {}", env!("CARGO_PKG_VERSION")),
222231
Conflict(a, b) => write!(f, "Option --{} conflicts with option {}.", a, b),
223232
Useless(a, false, b) => write!(f, "Option --{} is useless without option --{}.", a, b),
224233
Useless(a, true, b) => write!(f, "Option --{} is useless given option --{}.", a, b),

0 commit comments

Comments
 (0)