Merge pull request #48 from killercup/feature/optional-git-column

Make Git Column Optional
This commit is contained in:
Ben S 2015-03-11 14:56:16 +00:00
commit 2f03341209
2 changed files with 18 additions and 1 deletions

View File

@ -16,6 +16,7 @@
- **-B**, **--bytes**: list file sizes in bytes, without prefixes
- **-d**, **--list-dirs**: list directories as regular files
- **-g**, **--group**: show group as well as user
- **--git**: show git status (depends on libgit2, see below)
- **-h**, **--header**: show a header row
- **-H**, **--links**: show number of hard links column
- **-i**, **--inode**: show inode number column

View File

@ -72,6 +72,10 @@ impl Options {
opts.optflag("", "version", "display version of exa");
opts.optflag("?", "help", "show list of command-line options");
if cfg!(feature="git") {
opts.optflag("", "git", "show git status");
}
if xattr::feature_implemented() {
opts.optflag("@", "extended", "display extended attribute keys and sizes in long (-l) output");
}
@ -275,6 +279,9 @@ impl View {
else if matches.opt_present("blocks") {
Err(Misfire::Useless("blocks", false, "long"))
}
else if cfg!(feature="git") && matches.opt_present("git") {
Err(Misfire::Useless("git", false, "long"))
}
else if matches.opt_present("time") {
Err(Misfire::Useless("time", false, "long"))
}
@ -490,6 +497,7 @@ pub struct Columns {
links: bool,
blocks: bool,
group: bool,
git: bool
}
impl Columns {
@ -501,6 +509,7 @@ impl Columns {
links: matches.opt_present("links"),
blocks: matches.opt_present("blocks"),
group: matches.opt_present("group"),
git: matches.opt_present("git"),
})
}
@ -545,7 +554,7 @@ impl Columns {
if cfg!(feature="git") {
if let Some(d) = dir {
if d.has_git_repo() {
if self.git && d.has_git_repo() {
columns.push(GitStatus);
}
}
@ -647,6 +656,13 @@ mod test {
assert_eq!(opts.unwrap_err(), Misfire::Useless("blocks", false, "long"))
}
#[test]
#[cfg(feature="git")]
fn just_git() {
let opts = Options::getopts(&[ "--git".to_string() ]);
assert_eq!(opts.unwrap_err(), Misfire::Useless("git", false, "long"))
}
#[test]
fn extended_without_long() {
if xattr::feature_implemented() {