view.rs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. use output::{View, Mode, grid, details};
  2. use output::grid_details::{self, RowThreshold};
  3. use output::table::{TimeTypes, Environment, SizeFormat, Columns, Options as TableOptions};
  4. use output::time::TimeFormat;
  5. use options::{flags, Misfire, Vars};
  6. use options::parser::MatchedFlags;
  7. use fs::feature::xattr;
  8. impl View {
  9. /// Determine which view to use and all of that view’s arguments.
  10. pub fn deduce<V: Vars>(matches: &MatchedFlags, vars: &V) -> Result<View, Misfire> {
  11. use options::style::Styles;
  12. let mode = Mode::deduce(matches, vars)?;
  13. let Styles { colours, style } = Styles::deduce(matches, vars, || *TERM_WIDTH)?;
  14. Ok(View { mode, colours, style })
  15. }
  16. }
  17. impl Mode {
  18. /// Determine the mode from the command-line arguments.
  19. pub fn deduce<V: Vars>(matches: &MatchedFlags, vars: &V) -> Result<Mode, Misfire> {
  20. use options::misfire::Misfire::*;
  21. let long = || {
  22. if matches.has(&flags::ACROSS)? && !matches.has(&flags::GRID)? {
  23. Err(Useless(&flags::ACROSS, true, &flags::LONG))
  24. }
  25. else if matches.has(&flags::ONE_LINE)? {
  26. Err(Useless(&flags::ONE_LINE, true, &flags::LONG))
  27. }
  28. else {
  29. Ok(details::Options {
  30. table: Some(TableOptions::deduce(matches)?),
  31. header: matches.has(&flags::HEADER)?,
  32. xattr: xattr::ENABLED && matches.has(&flags::EXTENDED)?,
  33. })
  34. }
  35. };
  36. let other_options_scan = || {
  37. if let Some(width) = TerminalWidth::deduce(vars)?.width() {
  38. if matches.has(&flags::ONE_LINE)? {
  39. if matches.has(&flags::ACROSS)? {
  40. Err(Useless(&flags::ACROSS, true, &flags::ONE_LINE))
  41. }
  42. else {
  43. Ok(Mode::Lines)
  44. }
  45. }
  46. else if matches.has(&flags::TREE)? {
  47. let details = details::Options {
  48. table: None,
  49. header: false,
  50. xattr: xattr::ENABLED && matches.has(&flags::EXTENDED)?,
  51. };
  52. Ok(Mode::Details(details))
  53. }
  54. else {
  55. let grid = grid::Options {
  56. across: matches.has(&flags::ACROSS)?,
  57. console_width: width,
  58. };
  59. Ok(Mode::Grid(grid))
  60. }
  61. }
  62. else {
  63. // If the terminal width couldn’t be matched for some reason, such
  64. // as the program’s stdout being connected to a file, then
  65. // fallback to the lines view.
  66. if matches.has(&flags::TREE)? {
  67. let details = details::Options {
  68. table: None,
  69. header: false,
  70. xattr: xattr::ENABLED && matches.has(&flags::EXTENDED)?,
  71. };
  72. Ok(Mode::Details(details))
  73. }
  74. else {
  75. Ok(Mode::Lines)
  76. }
  77. }
  78. };
  79. if matches.has(&flags::LONG)? {
  80. let details = long()?;
  81. if matches.has(&flags::GRID)? {
  82. let other_options_mode = other_options_scan()?;
  83. if let Mode::Grid(grid) = other_options_mode {
  84. let row_threshold = RowThreshold::deduce(vars)?;
  85. return Ok(Mode::GridDetails(grid_details::Options { grid, details, row_threshold }));
  86. }
  87. else {
  88. return Ok(other_options_mode);
  89. }
  90. }
  91. else {
  92. return Ok(Mode::Details(details));
  93. }
  94. }
  95. // If --long hasn’t been passed, then check if we need to warn the
  96. // user about flags that won’t have any effect.
  97. if matches.is_strict() {
  98. for option in &[ &flags::BINARY, &flags::BYTES, &flags::INODE, &flags::LINKS,
  99. &flags::HEADER, &flags::BLOCKS, &flags::TIME, &flags::GROUP ] {
  100. if matches.has(option)? {
  101. return Err(Useless(*option, false, &flags::LONG));
  102. }
  103. }
  104. if cfg!(feature="git") && matches.has(&flags::GIT)? {
  105. return Err(Useless(&flags::GIT, false, &flags::LONG));
  106. }
  107. else if matches.has(&flags::LEVEL)? && !matches.has(&flags::RECURSE)? && !matches.has(&flags::TREE)? {
  108. // TODO: I'm not sure if the code even gets this far.
  109. // There is an identical check in dir_action
  110. return Err(Useless2(&flags::LEVEL, &flags::RECURSE, &flags::TREE));
  111. }
  112. }
  113. other_options_scan()
  114. }
  115. }
  116. /// The width of the terminal requested by the user.
  117. #[derive(PartialEq, Debug)]
  118. enum TerminalWidth {
  119. /// The user requested this specific number of columns.
  120. Set(usize),
  121. /// The terminal was found to have this number of columns.
  122. Terminal(usize),
  123. /// The user didn’t request any particular terminal width.
  124. Unset,
  125. }
  126. impl TerminalWidth {
  127. /// Determine a requested terminal width from the command-line arguments.
  128. ///
  129. /// Returns an error if a requested width doesn’t parse to an integer.
  130. fn deduce<V: Vars>(vars: &V) -> Result<TerminalWidth, Misfire> {
  131. use options::vars;
  132. if let Some(columns) = vars.get(vars::COLUMNS).and_then(|s| s.into_string().ok()) {
  133. match columns.parse() {
  134. Ok(width) => Ok(TerminalWidth::Set(width)),
  135. Err(e) => Err(Misfire::FailedParse(e)),
  136. }
  137. }
  138. else if let Some(width) = *TERM_WIDTH {
  139. Ok(TerminalWidth::Terminal(width))
  140. }
  141. else {
  142. Ok(TerminalWidth::Unset)
  143. }
  144. }
  145. fn width(&self) -> Option<usize> {
  146. match *self {
  147. TerminalWidth::Set(width) |
  148. TerminalWidth::Terminal(width) => Some(width),
  149. TerminalWidth::Unset => None,
  150. }
  151. }
  152. }
  153. impl RowThreshold {
  154. /// Determine whether to use a row threshold based on the given
  155. /// environment variables.
  156. fn deduce<V: Vars>(vars: &V) -> Result<RowThreshold, Misfire> {
  157. use options::vars;
  158. if let Some(columns) = vars.get(vars::EXA_GRID_ROWS).and_then(|s| s.into_string().ok()) {
  159. match columns.parse() {
  160. Ok(rows) => Ok(RowThreshold::MinimumRows(rows)),
  161. Err(e) => Err(Misfire::FailedParse(e)),
  162. }
  163. }
  164. else {
  165. Ok(RowThreshold::AlwaysGrid)
  166. }
  167. }
  168. }
  169. impl TableOptions {
  170. fn deduce(matches: &MatchedFlags) -> Result<Self, Misfire> {
  171. let env = Environment::load_all();
  172. let time_format = TimeFormat::deduce(matches)?;
  173. let size_format = SizeFormat::deduce(matches)?;
  174. let extra_columns = Columns::deduce(matches)?;
  175. Ok(TableOptions { env, time_format, size_format, extra_columns })
  176. }
  177. }
  178. impl Columns {
  179. fn deduce(matches: &MatchedFlags) -> Result<Self, Misfire> {
  180. let time_types = TimeTypes::deduce(matches)?;
  181. let git = cfg!(feature="git") && matches.has(&flags::GIT)?;
  182. let blocks = matches.has(&flags::BLOCKS)?;
  183. let group = matches.has(&flags::GROUP)?;
  184. let inode = matches.has(&flags::INODE)?;
  185. let links = matches.has(&flags::LINKS)?;
  186. Ok(Columns { time_types, git, blocks, group, inode, links })
  187. }
  188. }
  189. impl SizeFormat {
  190. /// Determine which file size to use in the file size column based on
  191. /// the user’s options.
  192. ///
  193. /// The default mode is to use the decimal prefixes, as they are the
  194. /// most commonly-understood, and don’t involve trying to parse large
  195. /// strings of digits in your head. Changing the format to anything else
  196. /// involves the `--binary` or `--bytes` flags, and these conflict with
  197. /// each other.
  198. fn deduce(matches: &MatchedFlags) -> Result<SizeFormat, Misfire> {
  199. let flag = matches.has_where(|f| f.matches(&flags::BINARY) || f.matches(&flags::BYTES))?;
  200. Ok(match flag {
  201. Some(f) if f.matches(&flags::BINARY) => SizeFormat::BinaryBytes,
  202. Some(f) if f.matches(&flags::BYTES) => SizeFormat::JustBytes,
  203. _ => SizeFormat::DecimalBytes,
  204. })
  205. }
  206. }
  207. impl TimeFormat {
  208. /// Determine how time should be formatted in timestamp columns.
  209. fn deduce(matches: &MatchedFlags) -> Result<TimeFormat, Misfire> {
  210. pub use output::time::{DefaultFormat, ISOFormat};
  211. let word = match matches.get(&flags::TIME_STYLE)? {
  212. Some(w) => w,
  213. None => return Ok(TimeFormat::DefaultFormat(DefaultFormat::new())),
  214. };
  215. if word == "default" {
  216. Ok(TimeFormat::DefaultFormat(DefaultFormat::new()))
  217. }
  218. else if word == "iso" {
  219. Ok(TimeFormat::ISOFormat(ISOFormat::new()))
  220. }
  221. else if word == "long-iso" {
  222. Ok(TimeFormat::LongISO)
  223. }
  224. else if word == "full-iso" {
  225. Ok(TimeFormat::FullISO)
  226. }
  227. else {
  228. Err(Misfire::BadArgument(&flags::TIME_STYLE, word.into()))
  229. }
  230. }
  231. }
  232. impl TimeTypes {
  233. /// Determine which of a file’s time fields should be displayed for it
  234. /// based on the user’s options.
  235. ///
  236. /// There are two separate ways to pick which fields to show: with a
  237. /// flag (such as `--modified`) or with a parameter (such as
  238. /// `--time=modified`). An error is signaled if both ways are used.
  239. ///
  240. /// It’s valid to show more than one column by passing in more than one
  241. /// option, but passing *no* options means that the user just wants to
  242. /// see the default set.
  243. fn deduce(matches: &MatchedFlags) -> Result<TimeTypes, Misfire> {
  244. let possible_word = matches.get(&flags::TIME)?;
  245. let modified = matches.has(&flags::MODIFIED)?;
  246. let created = matches.has(&flags::CREATED)?;
  247. let accessed = matches.has(&flags::ACCESSED)?;
  248. if let Some(word) = possible_word {
  249. if modified {
  250. Err(Misfire::Useless(&flags::MODIFIED, true, &flags::TIME))
  251. }
  252. else if created {
  253. Err(Misfire::Useless(&flags::CREATED, true, &flags::TIME))
  254. }
  255. else if accessed {
  256. Err(Misfire::Useless(&flags::ACCESSED, true, &flags::TIME))
  257. }
  258. else if word == "mod" || word == "modified" {
  259. Ok(TimeTypes { accessed: false, modified: true, created: false })
  260. }
  261. else if word == "acc" || word == "accessed" {
  262. Ok(TimeTypes { accessed: true, modified: false, created: false })
  263. }
  264. else if word == "cr" || word == "created" {
  265. Ok(TimeTypes { accessed: false, modified: false, created: true })
  266. }
  267. else {
  268. Err(Misfire::BadArgument(&flags::TIME, word.into()))
  269. }
  270. }
  271. else if modified || created || accessed {
  272. Ok(TimeTypes { accessed, modified, created })
  273. }
  274. else {
  275. Ok(TimeTypes::default())
  276. }
  277. }
  278. }
  279. // Gets, then caches, the width of the terminal that exa is running in.
  280. // This gets used multiple times above, with no real guarantee of order,
  281. // so it’s easier to just cache it the first time it runs.
  282. lazy_static! {
  283. static ref TERM_WIDTH: Option<usize> = {
  284. // All of stdin, stdout, and stderr could not be connected to a
  285. // terminal, but we’re only interested in stdout because it’s
  286. // where the output goes.
  287. use term_size::dimensions_stdout;
  288. dimensions_stdout().map(|t| t.0)
  289. };
  290. }
  291. #[cfg(test)]
  292. mod test {
  293. use super::*;
  294. use std::ffi::OsString;
  295. use options::flags;
  296. use options::parser::{Flag, Arg};
  297. use options::test::parse_for_test;
  298. use options::test::Strictnesses::*;
  299. static TEST_ARGS: &[&Arg] = &[ &flags::BINARY, &flags::BYTES, &flags::TIME_STYLE,
  300. &flags::TIME, &flags::MODIFIED, &flags::CREATED, &flags::ACCESSED,
  301. &flags::HEADER, &flags::GROUP, &flags::INODE, &flags::GIT,
  302. &flags::LINKS, &flags::BLOCKS, &flags::LONG, &flags::LEVEL,
  303. &flags::GRID, &flags::ACROSS, &flags::ONE_LINE ];
  304. macro_rules! test {
  305. ($name:ident: $type:ident <- $inputs:expr; $stricts:expr => $result:expr) => {
  306. /// Macro that writes a test.
  307. /// If testing both strictnesses, they’ll both be done in the same function.
  308. #[test]
  309. fn $name() {
  310. for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) {
  311. assert_eq!(result, $result);
  312. }
  313. }
  314. };
  315. ($name:ident: $type:ident <- $inputs:expr; $stricts:expr => err $result:expr) => {
  316. /// Special macro for testing Err results.
  317. /// This is needed because sometimes the Ok type doesn’t implement PartialEq.
  318. #[test]
  319. fn $name() {
  320. for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) {
  321. assert_eq!(result.unwrap_err(), $result);
  322. }
  323. }
  324. };
  325. ($name:ident: $type:ident <- $inputs:expr; $stricts:expr => like $pat:pat) => {
  326. /// More general macro for testing against a pattern.
  327. /// Instead of using PartialEq, this just tests if it matches a pat.
  328. #[test]
  329. fn $name() {
  330. for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) {
  331. println!("Testing {:?}", result);
  332. match result {
  333. $pat => assert!(true),
  334. _ => assert!(false),
  335. }
  336. }
  337. }
  338. };
  339. ($name:ident: $type:ident <- $inputs:expr, $vars:expr; $stricts:expr => err $result:expr) => {
  340. /// Like above, but with $vars.
  341. #[test]
  342. fn $name() {
  343. for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf, &$vars)) {
  344. assert_eq!(result.unwrap_err(), $result);
  345. }
  346. }
  347. };
  348. ($name:ident: $type:ident <- $inputs:expr, $vars:expr; $stricts:expr => like $pat:pat) => {
  349. /// Like further above, but with $vars.
  350. #[test]
  351. fn $name() {
  352. for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf, &$vars)) {
  353. println!("Testing {:?}", result);
  354. match result {
  355. $pat => assert!(true),
  356. _ => assert!(false),
  357. }
  358. }
  359. }
  360. };
  361. }
  362. mod size_formats {
  363. use super::*;
  364. // Default behaviour
  365. test!(empty: SizeFormat <- []; Both => Ok(SizeFormat::DecimalBytes));
  366. // Individual flags
  367. test!(binary: SizeFormat <- ["--binary"]; Both => Ok(SizeFormat::BinaryBytes));
  368. test!(bytes: SizeFormat <- ["--bytes"]; Both => Ok(SizeFormat::JustBytes));
  369. // Overriding
  370. test!(both_1: SizeFormat <- ["--binary", "--binary"]; Last => Ok(SizeFormat::BinaryBytes));
  371. test!(both_2: SizeFormat <- ["--bytes", "--binary"]; Last => Ok(SizeFormat::BinaryBytes));
  372. test!(both_3: SizeFormat <- ["--binary", "--bytes"]; Last => Ok(SizeFormat::JustBytes));
  373. test!(both_4: SizeFormat <- ["--bytes", "--bytes"]; Last => Ok(SizeFormat::JustBytes));
  374. test!(both_5: SizeFormat <- ["--binary", "--binary"]; Complain => err Misfire::Duplicate(Flag::Long("binary"), Flag::Long("binary")));
  375. test!(both_6: SizeFormat <- ["--bytes", "--binary"]; Complain => err Misfire::Duplicate(Flag::Long("bytes"), Flag::Long("binary")));
  376. test!(both_7: SizeFormat <- ["--binary", "--bytes"]; Complain => err Misfire::Duplicate(Flag::Long("binary"), Flag::Long("bytes")));
  377. test!(both_8: SizeFormat <- ["--bytes", "--bytes"]; Complain => err Misfire::Duplicate(Flag::Long("bytes"), Flag::Long("bytes")));
  378. }
  379. mod time_formats {
  380. use super::*;
  381. // These tests use pattern matching because TimeFormat doesn’t
  382. // implement PartialEq.
  383. // Default behaviour
  384. test!(empty: TimeFormat <- []; Both => like Ok(TimeFormat::DefaultFormat(_)));
  385. // Individual settings
  386. test!(default: TimeFormat <- ["--time-style=default"]; Both => like Ok(TimeFormat::DefaultFormat(_)));
  387. test!(iso: TimeFormat <- ["--time-style", "iso"]; Both => like Ok(TimeFormat::ISOFormat(_)));
  388. test!(long_iso: TimeFormat <- ["--time-style=long-iso"]; Both => like Ok(TimeFormat::LongISO));
  389. test!(full_iso: TimeFormat <- ["--time-style", "full-iso"]; Both => like Ok(TimeFormat::FullISO));
  390. // Overriding
  391. test!(actually: TimeFormat <- ["--time-style=default", "--time-style", "iso"]; Last => like Ok(TimeFormat::ISOFormat(_)));
  392. test!(actual_2: TimeFormat <- ["--time-style=default", "--time-style", "iso"]; Complain => err Misfire::Duplicate(Flag::Long("time-style"), Flag::Long("time-style")));
  393. test!(nevermind: TimeFormat <- ["--time-style", "long-iso", "--time-style=full-iso"]; Last => like Ok(TimeFormat::FullISO));
  394. test!(nevermore: TimeFormat <- ["--time-style", "long-iso", "--time-style=full-iso"]; Complain => err Misfire::Duplicate(Flag::Long("time-style"), Flag::Long("time-style")));
  395. // Errors
  396. test!(daily: TimeFormat <- ["--time-style=24-hour"]; Both => err Misfire::BadArgument(&flags::TIME_STYLE, OsString::from("24-hour")));
  397. }
  398. mod time_types {
  399. use super::*;
  400. // Default behaviour
  401. test!(empty: TimeTypes <- []; Both => Ok(TimeTypes::default()));
  402. // Modified
  403. test!(modified: TimeTypes <- ["--modified"]; Both => Ok(TimeTypes { accessed: false, modified: true, created: false }));
  404. test!(m: TimeTypes <- ["-m"]; Both => Ok(TimeTypes { accessed: false, modified: true, created: false }));
  405. test!(time_mod: TimeTypes <- ["--time=modified"]; Both => Ok(TimeTypes { accessed: false, modified: true, created: false }));
  406. test!(time_m: TimeTypes <- ["-tmod"]; Both => Ok(TimeTypes { accessed: false, modified: true, created: false }));
  407. // Accessed
  408. test!(acc: TimeTypes <- ["--accessed"]; Both => Ok(TimeTypes { accessed: true, modified: false, created: false }));
  409. test!(a: TimeTypes <- ["-u"]; Both => Ok(TimeTypes { accessed: true, modified: false, created: false }));
  410. test!(time_acc: TimeTypes <- ["--time", "accessed"]; Both => Ok(TimeTypes { accessed: true, modified: false, created: false }));
  411. test!(time_a: TimeTypes <- ["-t", "acc"]; Both => Ok(TimeTypes { accessed: true, modified: false, created: false }));
  412. // Created
  413. test!(cr: TimeTypes <- ["--created"]; Both => Ok(TimeTypes { accessed: false, modified: false, created: true }));
  414. test!(c: TimeTypes <- ["-U"]; Both => Ok(TimeTypes { accessed: false, modified: false, created: true }));
  415. test!(time_cr: TimeTypes <- ["--time=created"]; Both => Ok(TimeTypes { accessed: false, modified: false, created: true }));
  416. test!(time_c: TimeTypes <- ["-tcr"]; Both => Ok(TimeTypes { accessed: false, modified: false, created: true }));
  417. // Multiples
  418. test!(time_uu: TimeTypes <- ["-uU"]; Both => Ok(TimeTypes { accessed: true, modified: false, created: true }));
  419. // Errors
  420. test!(time_tea: TimeTypes <- ["--time=tea"]; Both => err Misfire::BadArgument(&flags::TIME, OsString::from("tea")));
  421. test!(time_ea: TimeTypes <- ["-tea"]; Both => err Misfire::BadArgument(&flags::TIME, OsString::from("ea")));
  422. // Overriding
  423. test!(overridden: TimeTypes <- ["-tcr", "-tmod"]; Last => Ok(TimeTypes { accessed: false, modified: true, created: false }));
  424. test!(overridden_2: TimeTypes <- ["-tcr", "-tmod"]; Complain => err Misfire::Duplicate(Flag::Short(b't'), Flag::Short(b't')));
  425. }
  426. mod views {
  427. use super::*;
  428. use output::grid::Options as GridOptions;
  429. // Default
  430. test!(empty: Mode <- [], None; Both => like Ok(Mode::Grid(_)));
  431. // Grid views
  432. test!(original_g: Mode <- ["-G"], None; Both => like Ok(Mode::Grid(GridOptions { across: false, console_width: _ })));
  433. test!(grid: Mode <- ["--grid"], None; Both => like Ok(Mode::Grid(GridOptions { across: false, console_width: _ })));
  434. test!(across: Mode <- ["--across"], None; Both => like Ok(Mode::Grid(GridOptions { across: true, console_width: _ })));
  435. test!(gracross: Mode <- ["-xG"], None; Both => like Ok(Mode::Grid(GridOptions { across: true, console_width: _ })));
  436. // Lines views
  437. test!(lines: Mode <- ["--oneline"], None; Both => like Ok(Mode::Lines));
  438. test!(prima: Mode <- ["-1"], None; Both => like Ok(Mode::Lines));
  439. // Details views
  440. test!(long: Mode <- ["--long"], None; Both => like Ok(Mode::Details(_)));
  441. test!(ell: Mode <- ["-l"], None; Both => like Ok(Mode::Details(_)));
  442. // Grid-details views
  443. test!(lid: Mode <- ["--long", "--grid"], None; Both => like Ok(Mode::GridDetails(_)));
  444. test!(leg: Mode <- ["-lG"], None; Both => like Ok(Mode::GridDetails(_)));
  445. // Options that do nothing without --long
  446. test!(just_header: Mode <- ["--header"], None; Last => like Ok(Mode::Grid(_)));
  447. test!(just_group: Mode <- ["--group"], None; Last => like Ok(Mode::Grid(_)));
  448. test!(just_inode: Mode <- ["--inode"], None; Last => like Ok(Mode::Grid(_)));
  449. test!(just_links: Mode <- ["--links"], None; Last => like Ok(Mode::Grid(_)));
  450. test!(just_blocks: Mode <- ["--blocks"], None; Last => like Ok(Mode::Grid(_)));
  451. test!(just_binary: Mode <- ["--binary"], None; Last => like Ok(Mode::Grid(_)));
  452. test!(just_bytes: Mode <- ["--bytes"], None; Last => like Ok(Mode::Grid(_)));
  453. #[cfg(feature="git")]
  454. test!(just_git: Mode <- ["--git"], None; Last => like Ok(Mode::Grid(_)));
  455. test!(just_header_2: Mode <- ["--header"], None; Complain => err Misfire::Useless(&flags::HEADER, false, &flags::LONG));
  456. test!(just_group_2: Mode <- ["--group"], None; Complain => err Misfire::Useless(&flags::GROUP, false, &flags::LONG));
  457. test!(just_inode_2: Mode <- ["--inode"], None; Complain => err Misfire::Useless(&flags::INODE, false, &flags::LONG));
  458. test!(just_links_2: Mode <- ["--links"], None; Complain => err Misfire::Useless(&flags::LINKS, false, &flags::LONG));
  459. test!(just_blocks_2: Mode <- ["--blocks"], None; Complain => err Misfire::Useless(&flags::BLOCKS, false, &flags::LONG));
  460. test!(just_binary_2: Mode <- ["--binary"], None; Complain => err Misfire::Useless(&flags::BINARY, false, &flags::LONG));
  461. test!(just_bytes_2: Mode <- ["--bytes"], None; Complain => err Misfire::Useless(&flags::BYTES, false, &flags::LONG));
  462. #[cfg(feature="git")]
  463. test!(just_git_2: Mode <- ["--git"], None; Complain => err Misfire::Useless(&flags::GIT, false, &flags::LONG));
  464. }
  465. }