diff options
author | Ben S <ogham@bsago.me> | 2015-02-23 14:52:07 +0000 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2015-02-23 14:52:07 +0000 |
commit | ce23c63d759e3f19f59c91ebaa776d5b7a8746ac (patch) | |
tree | 354dca32c27c2c63a3a7d03b3faef882d0a87f1f /src/options.rs | |
parent | 38a785426bda54db3adeeb7edf991fd8c4d78e30 (diff) | |
parent | 586c7dd30b2091d2b9fa3dc53b0af0aa2feb0b0f (diff) |
Merge branch 'nwin:add-xattr-linux'
Conflicts:
src/file.rs
Diffstat (limited to 'src/options.rs')
-rw-r--r-- | src/options.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/options.rs b/src/options.rs index 749d60c..a50bad8 100644 --- a/src/options.rs +++ b/src/options.rs @@ -4,6 +4,7 @@ use column::Column; use column::Column::*; use output::{Grid, Details}; use term::dimensions; +use xattr; use std::cmp::Ordering; use std::fmt; @@ -43,6 +44,11 @@ impl Options { /// Call getopts on the given slice of command-line strings. pub fn getopts(args: &[String]) -> Result<(Options, Vec<String>), Misfire> { let mut opts = getopts::Options::new(); + if xattr::feature_implemented() { + opts.optflag("@", "extended", + "display extended attribute keys and sizes in long (-l) output" + ); + } opts.optflag("1", "oneline", "display one entry per line"); opts.optflag("a", "all", "show dot-files"); opts.optflag("b", "binary", "use binary prefixes in file sizes"); @@ -215,6 +221,7 @@ impl View { columns: try!(Columns::deduce(matches)), header: matches.opt_present("header"), tree: matches.opt_present("recurse"), + xattr: xattr::feature_implemented() && matches.opt_present("extended"), filter: filter, }; @@ -245,6 +252,9 @@ impl View { else if matches.opt_present("tree") { Err(Misfire::Useless("tree", false, "long")) } + else if xattr::feature_implemented() && matches.opt_present("extended") { + Err(Misfire::Useless("extended", false, "long")) + } else if matches.opt_present("oneline") { if matches.opt_present("across") { Err(Misfire::Useless("across", true, "oneline")) @@ -461,6 +471,7 @@ mod test { use super::Options; use super::Misfire; use super::Misfire::*; + use xattr; fn is_helpful<T>(misfire: Result<T, Misfire>) -> bool { match misfire { @@ -548,6 +559,14 @@ mod test { } #[test] + fn extended_without_long() { + if xattr::feature_implemented() { + let opts = Options::getopts(&[ "--extended".to_string() ]); + assert_eq!(opts.unwrap_err(), Misfire::Useless("extended", false, "long")) + } + } + + #[test] fn tree_without_recurse() { let opts = Options::getopts(&[ "--tree".to_string() ]); assert_eq!(opts.unwrap_err(), Misfire::Useless("tree", false, "recurse")) |