mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-28 02:35:03 +00:00
Merge pull request #48 from killercup/feature/optional-git-column
Make Git Column Optional
This commit is contained in:
commit
2f03341209
@ -16,6 +16,7 @@
|
|||||||
- **-B**, **--bytes**: list file sizes in bytes, without prefixes
|
- **-B**, **--bytes**: list file sizes in bytes, without prefixes
|
||||||
- **-d**, **--list-dirs**: list directories as regular files
|
- **-d**, **--list-dirs**: list directories as regular files
|
||||||
- **-g**, **--group**: show group as well as user
|
- **-g**, **--group**: show group as well as user
|
||||||
|
- **--git**: show git status (depends on libgit2, see below)
|
||||||
- **-h**, **--header**: show a header row
|
- **-h**, **--header**: show a header row
|
||||||
- **-H**, **--links**: show number of hard links column
|
- **-H**, **--links**: show number of hard links column
|
||||||
- **-i**, **--inode**: show inode number column
|
- **-i**, **--inode**: show inode number column
|
||||||
|
@ -72,6 +72,10 @@ impl Options {
|
|||||||
opts.optflag("", "version", "display version of exa");
|
opts.optflag("", "version", "display version of exa");
|
||||||
opts.optflag("?", "help", "show list of command-line options");
|
opts.optflag("?", "help", "show list of command-line options");
|
||||||
|
|
||||||
|
if cfg!(feature="git") {
|
||||||
|
opts.optflag("", "git", "show git status");
|
||||||
|
}
|
||||||
|
|
||||||
if xattr::feature_implemented() {
|
if xattr::feature_implemented() {
|
||||||
opts.optflag("@", "extended", "display extended attribute keys and sizes in long (-l) output");
|
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") {
|
else if matches.opt_present("blocks") {
|
||||||
Err(Misfire::Useless("blocks", false, "long"))
|
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") {
|
else if matches.opt_present("time") {
|
||||||
Err(Misfire::Useless("time", false, "long"))
|
Err(Misfire::Useless("time", false, "long"))
|
||||||
}
|
}
|
||||||
@ -490,6 +497,7 @@ pub struct Columns {
|
|||||||
links: bool,
|
links: bool,
|
||||||
blocks: bool,
|
blocks: bool,
|
||||||
group: bool,
|
group: bool,
|
||||||
|
git: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Columns {
|
impl Columns {
|
||||||
@ -501,6 +509,7 @@ impl Columns {
|
|||||||
links: matches.opt_present("links"),
|
links: matches.opt_present("links"),
|
||||||
blocks: matches.opt_present("blocks"),
|
blocks: matches.opt_present("blocks"),
|
||||||
group: matches.opt_present("group"),
|
group: matches.opt_present("group"),
|
||||||
|
git: matches.opt_present("git"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,7 +554,7 @@ impl Columns {
|
|||||||
|
|
||||||
if cfg!(feature="git") {
|
if cfg!(feature="git") {
|
||||||
if let Some(d) = dir {
|
if let Some(d) = dir {
|
||||||
if d.has_git_repo() {
|
if self.git && d.has_git_repo() {
|
||||||
columns.push(GitStatus);
|
columns.push(GitStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -647,6 +656,13 @@ mod test {
|
|||||||
assert_eq!(opts.unwrap_err(), Misfire::Useless("blocks", false, "long"))
|
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]
|
#[test]
|
||||||
fn extended_without_long() {
|
fn extended_without_long() {
|
||||||
if xattr::feature_implemented() {
|
if xattr::feature_implemented() {
|
||||||
|
Loading…
Reference in New Issue
Block a user