|
@@ -4,6 +4,7 @@ use column::Column;
|
|
|
use column::Column::*;
|
|
use column::Column::*;
|
|
|
use output::{Grid, Details};
|
|
use output::{Grid, Details};
|
|
|
use term::dimensions;
|
|
use term::dimensions;
|
|
|
|
|
+use xattr;
|
|
|
|
|
|
|
|
use std::cmp::Ordering;
|
|
use std::cmp::Ordering;
|
|
|
use std::fmt;
|
|
use std::fmt;
|
|
@@ -43,6 +44,11 @@ impl Options {
|
|
|
/// Call getopts on the given slice of command-line strings.
|
|
/// Call getopts on the given slice of command-line strings.
|
|
|
pub fn getopts(args: &[String]) -> Result<(Options, Vec<String>), Misfire> {
|
|
pub fn getopts(args: &[String]) -> Result<(Options, Vec<String>), Misfire> {
|
|
|
let mut opts = getopts::Options::new();
|
|
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("1", "oneline", "display one entry per line");
|
|
|
opts.optflag("a", "all", "show dot-files");
|
|
opts.optflag("a", "all", "show dot-files");
|
|
|
opts.optflag("b", "binary", "use binary prefixes in file sizes");
|
|
opts.optflag("b", "binary", "use binary prefixes in file sizes");
|
|
@@ -215,6 +221,7 @@ impl View {
|
|
|
columns: try!(Columns::deduce(matches)),
|
|
columns: try!(Columns::deduce(matches)),
|
|
|
header: matches.opt_present("header"),
|
|
header: matches.opt_present("header"),
|
|
|
tree: matches.opt_present("recurse"),
|
|
tree: matches.opt_present("recurse"),
|
|
|
|
|
+ xattr: xattr::feature_implemented() && matches.opt_present("extended"),
|
|
|
filter: filter,
|
|
filter: filter,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -245,6 +252,9 @@ impl View {
|
|
|
else if matches.opt_present("tree") {
|
|
else if matches.opt_present("tree") {
|
|
|
Err(Misfire::Useless("tree", false, "long"))
|
|
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") {
|
|
else if matches.opt_present("oneline") {
|
|
|
if matches.opt_present("across") {
|
|
if matches.opt_present("across") {
|
|
|
Err(Misfire::Useless("across", true, "oneline"))
|
|
Err(Misfire::Useless("across", true, "oneline"))
|
|
@@ -461,6 +471,7 @@ mod test {
|
|
|
use super::Options;
|
|
use super::Options;
|
|
|
use super::Misfire;
|
|
use super::Misfire;
|
|
|
use super::Misfire::*;
|
|
use super::Misfire::*;
|
|
|
|
|
+ use xattr;
|
|
|
|
|
|
|
|
fn is_helpful<T>(misfire: Result<T, Misfire>) -> bool {
|
|
fn is_helpful<T>(misfire: Result<T, Misfire>) -> bool {
|
|
|
match misfire {
|
|
match misfire {
|
|
@@ -547,6 +558,14 @@ mod test {
|
|
|
assert_eq!(opts.unwrap_err(), Misfire::Useless("blocks", false, "long"))
|
|
assert_eq!(opts.unwrap_err(), Misfire::Useless("blocks", false, "long"))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ #[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]
|
|
#[test]
|
|
|
fn tree_without_recurse() {
|
|
fn tree_without_recurse() {
|
|
|
let opts = Options::getopts(&[ "--tree".to_string() ]);
|
|
let opts = Options::getopts(&[ "--tree".to_string() ]);
|