2017-06-23 21:50:29 +00:00
|
|
|
use std::fmt;
|
2016-04-17 19:38:37 +00:00
|
|
|
|
2017-06-23 20:22:39 +00:00
|
|
|
|
|
|
|
static OPTIONS: &str = r##"
|
2017-05-06 22:00:45 +00:00
|
|
|
-?, --help show list of command-line options
|
|
|
|
-v, --version show version of exa
|
|
|
|
|
2016-04-17 19:38:37 +00:00
|
|
|
DISPLAY OPTIONS
|
|
|
|
-1, --oneline display one entry per line
|
2017-05-06 22:00:45 +00:00
|
|
|
-l, --long display extended file metadata as a table
|
|
|
|
-G, --grid display entries as a grid (default)
|
|
|
|
-x, --across sort the grid across, rather than downwards
|
2016-04-17 19:38:37 +00:00
|
|
|
-R, --recurse recurse into directories
|
2017-05-06 22:00:45 +00:00
|
|
|
-T, --tree recurse into directories as a tree
|
|
|
|
-F, --classify display type indicator by file names
|
|
|
|
--colo[u]r=WHEN when to use terminal colours (always, auto, never)
|
|
|
|
--colo[u]r-scale highlight levels of file sizes distinctly
|
2016-04-17 19:38:37 +00:00
|
|
|
|
|
|
|
FILTERING AND SORTING OPTIONS
|
2017-06-29 12:24:55 +00:00
|
|
|
-a, --all show hidden and 'dot' files
|
2017-05-06 22:00:45 +00:00
|
|
|
-d, --list-dirs list directories like regular files
|
|
|
|
-r, --reverse reverse the sort order
|
|
|
|
-s, --sort SORT_FIELD which field to sort by:
|
2016-04-17 19:38:37 +00:00
|
|
|
--group-directories-first list directories before other files
|
2016-10-30 14:47:38 +00:00
|
|
|
-I, --ignore-glob GLOBS glob patterns (pipe-separated) of files to ignore
|
2017-06-29 13:57:43 +00:00
|
|
|
Valid sort fields: name, Name, extension, Extension, size, type,
|
2017-05-06 22:00:45 +00:00
|
|
|
modified, accessed, created, inode, none
|
2016-04-17 19:38:37 +00:00
|
|
|
"##;
|
|
|
|
|
2017-06-23 20:22:39 +00:00
|
|
|
static LONG_OPTIONS: &str = r##"
|
2016-04-17 19:38:37 +00:00
|
|
|
LONG VIEW OPTIONS
|
2017-05-06 22:00:45 +00:00
|
|
|
-b, --binary list file sizes with binary prefixes
|
|
|
|
-B, --bytes list file sizes in bytes, without any prefixes
|
|
|
|
-g, --group list each file's group
|
|
|
|
-h, --header add a header row to each column
|
|
|
|
-H, --links list each file's number of hard links
|
|
|
|
-i, --inode list each file's inode number
|
|
|
|
-L, --level DEPTH limit the depth of recursion
|
|
|
|
-m, --modified use the modified timestamp field
|
2016-04-17 19:38:37 +00:00
|
|
|
-S, --blocks show number of file system blocks
|
2017-05-06 22:00:45 +00:00
|
|
|
-t, --time FIELD which timestamp field to list (modified, accessed, created)
|
|
|
|
-u, --accessed use the accessed timestamp field
|
2017-06-23 21:30:48 +00:00
|
|
|
-U, --created use the created timestamp field"##;
|
2016-04-17 19:38:37 +00:00
|
|
|
|
2017-06-23 20:22:39 +00:00
|
|
|
static GIT_HELP: &str = r##" --git list each file's Git status, if tracked"##;
|
|
|
|
static EXTENDED_HELP: &str = r##" -@, --extended list each file's extended attributes and sizes"##;
|
|
|
|
|
2017-06-23 21:50:29 +00:00
|
|
|
#[derive(PartialEq, Debug)]
|
|
|
|
pub struct HelpString {
|
|
|
|
pub only_long: bool,
|
|
|
|
pub git: bool,
|
|
|
|
pub xattrs: bool,
|
|
|
|
}
|
2017-06-23 20:22:39 +00:00
|
|
|
|
2017-06-23 21:50:29 +00:00
|
|
|
impl fmt::Display for HelpString {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
|
|
|
try!(write!(f, "Usage:\n exa [options] [files...]\n"));
|
2017-06-23 20:22:39 +00:00
|
|
|
|
2017-06-23 21:50:29 +00:00
|
|
|
if !self.only_long {
|
|
|
|
try!(write!(f, "{}", OPTIONS));
|
|
|
|
}
|
2017-06-23 20:22:39 +00:00
|
|
|
|
2017-06-23 21:50:29 +00:00
|
|
|
try!(write!(f, "{}", LONG_OPTIONS));
|
2017-06-23 20:22:39 +00:00
|
|
|
|
2017-06-23 21:50:29 +00:00
|
|
|
if self.git {
|
|
|
|
try!(write!(f, "\n{}", GIT_HELP));
|
|
|
|
}
|
2017-06-23 20:22:39 +00:00
|
|
|
|
2017-06-23 21:50:29 +00:00
|
|
|
if self.xattrs {
|
|
|
|
try!(write!(f, "\n{}", EXTENDED_HELP));
|
|
|
|
}
|
2017-06-23 20:22:39 +00:00
|
|
|
|
2017-06-23 21:50:29 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
2017-06-23 20:22:39 +00:00
|
|
|
}
|