@@ -68,6 +68,8 @@ impl Options {
68
68
opts. optflag ( "u" , "accessed" , "display timestamp of last access for a file" ) ;
69
69
opts. optflag ( "U" , "created" , "display timestamp of creation for a file" ) ;
70
70
opts. optflag ( "x" , "across" , "sort multi-column view entries across" ) ;
71
+
72
+ opts. optflag ( "" , "version" , "display version of exa" ) ;
71
73
opts. optflag ( "?" , "help" , "show list of command-line options" ) ;
72
74
73
75
if xattr:: feature_implemented ( ) {
@@ -82,6 +84,9 @@ impl Options {
82
84
if matches. opt_present ( "help" ) {
83
85
return Err ( Misfire :: Help ( opts. usage ( "Usage:\n exa [options] [files...]" ) ) ) ;
84
86
}
87
+ else if matches. opt_present ( "version" ) {
88
+ return Err ( Misfire :: Version ) ;
89
+ }
85
90
86
91
let sort_field = match matches. opt_str ( "sort" ) {
87
92
Some ( word) => try!( SortField :: from_word ( word) ) ,
@@ -191,6 +196,9 @@ pub enum Misfire {
191
196
/// this enum isn't named Error!
192
197
Help ( String ) ,
193
198
199
+ /// The user wanted the version number.
200
+ Version ,
201
+
194
202
/// Two options were given that conflict with one another.
195
203
Conflict ( & ' static str , & ' static str ) ,
196
204
@@ -219,6 +227,7 @@ impl fmt::Display for Misfire {
219
227
match * self {
220
228
InvalidOptions ( ref e) => write ! ( f, "{}" , e) ,
221
229
Help ( ref text) => write ! ( f, "{}" , text) ,
230
+ Version => write ! ( f, "exa {}" , env!( "CARGO_PKG_VERSION" ) ) ,
222
231
Conflict ( a, b) => write ! ( f, "Option --{} conflicts with option {}." , a, b) ,
223
232
Useless ( a, false , b) => write ! ( f, "Option --{} is useless without option --{}." , a, b) ,
224
233
Useless ( a, true , b) => write ! ( f, "Option --{} is useless given option --{}." , a, b) ,
0 commit comments