mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-06-06 09:20:49 +00:00
Merge pull request #762 from ariasuni/warm-when-git-feature-is-disabled
Warm when git feature is disabled instead of ignoring flags
This commit is contained in:
commit
e6edb888a0
|
@ -104,7 +104,7 @@ Sort fields starting with a capital letter will sort uppercase before lowercase:
|
||||||
`-I`, `--ignore-glob=GLOBS`
|
`-I`, `--ignore-glob=GLOBS`
|
||||||
: Glob patterns, pipe-separated, of files to ignore.
|
: Glob patterns, pipe-separated, of files to ignore.
|
||||||
|
|
||||||
`--git-ignore`
|
`--git-ignore` [if exa was built with git support]
|
||||||
: Do not list files that are ignored by Git.
|
: Do not list files that are ignored by Git.
|
||||||
|
|
||||||
`--group-directories-first`
|
`--group-directories-first`
|
||||||
|
@ -177,7 +177,7 @@ These options are available when running with `--long` (`-l`):
|
||||||
`-@`, `--extended`
|
`-@`, `--extended`
|
||||||
: List each file’s extended attributes and sizes.
|
: List each file’s extended attributes and sizes.
|
||||||
|
|
||||||
`--git`
|
`--git` [if exa was built with git support]
|
||||||
: List each file’s Git status, if tracked.
|
: List each file’s Git status, if tracked.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub mod git {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self, _index: &Path, _prefix_lookup: bool) -> f::Git {
|
pub fn get(&self, _index: &Path, _prefix_lookup: bool) -> f::Git {
|
||||||
panic!("Tried to query a Git cache, but Git support is disabled")
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,7 @@ use std::io;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
|
||||||
pub const ENABLED: bool =
|
pub const ENABLED: bool = cfg!(any(target_os = "macos", target_os = "linux"));
|
||||||
cfg!(feature="git") &&
|
|
||||||
cfg!(any(target_os = "macos", target_os = "linux"));
|
|
||||||
|
|
||||||
|
|
||||||
pub trait FileAttributes {
|
pub trait FileAttributes {
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub enum OptionsError {
|
||||||
/// The user supplied an illegal choice to an Argument.
|
/// The user supplied an illegal choice to an Argument.
|
||||||
BadArgument(&'static Arg, OsString),
|
BadArgument(&'static Arg, OsString),
|
||||||
|
|
||||||
/// The user supplied a set of options
|
/// The user supplied a set of options that are unsupported
|
||||||
Unsupported(String),
|
Unsupported(String),
|
||||||
|
|
||||||
/// An option was given twice or more in strict mode.
|
/// An option was given twice or more in strict mode.
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::options::flags;
|
||||||
use crate::options::parser::MatchedFlags;
|
use crate::options::parser::MatchedFlags;
|
||||||
|
|
||||||
|
|
||||||
static USAGE: &str = r##"Usage:
|
static USAGE_PART1: &str = "Usage:
|
||||||
exa [options] [files...]
|
exa [options] [files...]
|
||||||
|
|
||||||
META OPTIONS
|
META OPTIONS
|
||||||
|
@ -33,8 +33,9 @@ FILTERING AND SORTING OPTIONS
|
||||||
-s, --sort SORT_FIELD which field to sort by
|
-s, --sort SORT_FIELD which field to sort by
|
||||||
--group-directories-first list directories before other files
|
--group-directories-first list directories before other files
|
||||||
-D, --only-dirs list only directories
|
-D, --only-dirs list only directories
|
||||||
-I, --ignore-glob GLOBS glob patterns (pipe-separated) of files to ignore
|
-I, --ignore-glob GLOBS glob patterns (pipe-separated) of files to ignore";
|
||||||
--git-ignore ignore files mentioned in '.gitignore'
|
|
||||||
|
static USAGE_PART2: &str = " \
|
||||||
Valid sort fields: name, Name, extension, Extension, size, type,
|
Valid sort fields: name, Name, extension, Extension, size, type,
|
||||||
modified, accessed, created, inode, and none.
|
modified, accessed, created, inode, and none.
|
||||||
date, time, old, and new all refer to modified.
|
date, time, old, and new all refer to modified.
|
||||||
|
@ -57,10 +58,11 @@ LONG VIEW OPTIONS
|
||||||
--octal-permissions list each file's permission in octal format
|
--octal-permissions list each file's permission in octal format
|
||||||
--no-filesize suppress the filesize field
|
--no-filesize suppress the filesize field
|
||||||
--no-user suppress the user field
|
--no-user suppress the user field
|
||||||
--no-time suppress the time field"##;
|
--no-time suppress the time field";
|
||||||
|
|
||||||
static GIT_HELP: &str = r##" --git list each file's Git status, if tracked or ignored"##;
|
static GIT_FILTER_HELP: &str = " --git-ignore ignore files mentioned in '.gitignore'";
|
||||||
static EXTENDED_HELP: &str = r##" -@, --extended list each file's extended attributes and sizes"##;
|
static GIT_VIEW_HELP: &str = " --git list each file's Git status, if tracked or ignored";
|
||||||
|
static EXTENDED_HELP: &str = " -@, --extended list each file's extended attributes and sizes";
|
||||||
|
|
||||||
|
|
||||||
/// All the information needed to display the help text, which depends
|
/// All the information needed to display the help text, which depends
|
||||||
|
@ -93,14 +95,20 @@ impl fmt::Display for HelpString {
|
||||||
/// Format this help options into an actual string of help
|
/// Format this help options into an actual string of help
|
||||||
/// text to be displayed to the user.
|
/// text to be displayed to the user.
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||||
writeln!(f, "{}", USAGE)?;
|
write!(f, "{}", USAGE_PART1)?;
|
||||||
|
|
||||||
if cfg!(feature="git") {
|
if cfg!(feature = "git") {
|
||||||
writeln!(f, "{}", GIT_HELP)?;
|
write!(f, "\n{}", GIT_FILTER_HELP)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
write!(f, "\n{}", USAGE_PART2)?;
|
||||||
|
|
||||||
|
if cfg!(feature = "git") {
|
||||||
|
write!(f, "\n{}", GIT_VIEW_HELP)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if xattr::ENABLED {
|
if xattr::ENABLED {
|
||||||
writeln!(f, "{}", EXTENDED_HELP)?;
|
write!(f, "\n{}", EXTENDED_HELP)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -176,6 +176,13 @@ impl Options {
|
||||||
/// Determines the complete set of options based on the given command-line
|
/// Determines the complete set of options based on the given command-line
|
||||||
/// arguments, after they’ve been parsed.
|
/// arguments, after they’ve been parsed.
|
||||||
fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
|
fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
|
||||||
|
if cfg!(not(feature = "git")) &&
|
||||||
|
matches.has_where_any(|f| f.matches(&flags::GIT) || f.matches(&flags::GIT_IGNORE)).is_some() {
|
||||||
|
return Err(OptionsError::Unsupported(format!(
|
||||||
|
"Options --git and --git-ignore can't be used because `git` feature was disabled in this build of exa"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
let view = View::deduce(matches, vars)?;
|
let view = View::deduce(matches, vars)?;
|
||||||
let dir_action = DirAction::deduce(matches, matches!(view.mode, Mode::Details(_)))?;
|
let dir_action = DirAction::deduce(matches, matches!(view.mode, Mode::Details(_)))?;
|
||||||
let filter = FileFilter::deduce(matches)?;
|
let filter = FileFilter::deduce(matches)?;
|
||||||
|
|
|
@ -31,7 +31,11 @@ impl VersionString {
|
||||||
|
|
||||||
impl fmt::Display for VersionString {
|
impl fmt::Display for VersionString {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||||
writeln!(f, "{}", include!(concat!(env!("OUT_DIR"), "/version_string.txt")))
|
writeln!(
|
||||||
|
f,
|
||||||
|
"{} (git support: {})",
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/version_string.txt")),
|
||||||
|
if cfg!(feature = "git") { "enabled" } else { "disabled" })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ impl Mode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg!(feature = "git") && matches.has(&flags::GIT)? {
|
if matches.has(&flags::GIT)? {
|
||||||
return Err(OptionsError::Useless(&flags::GIT, false, &flags::LONG));
|
return Err(OptionsError::Useless(&flags::GIT, false, &flags::LONG));
|
||||||
}
|
}
|
||||||
else if matches.has(&flags::LEVEL)? && ! matches.has(&flags::RECURSE)? && ! matches.has(&flags::TREE)? {
|
else if matches.has(&flags::LEVEL)? && ! matches.has(&flags::RECURSE)? && ! matches.has(&flags::TREE)? {
|
||||||
|
@ -192,7 +192,7 @@ impl TableOptions {
|
||||||
impl Columns {
|
impl Columns {
|
||||||
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
|
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
|
||||||
let time_types = TimeTypes::deduce(matches)?;
|
let time_types = TimeTypes::deduce(matches)?;
|
||||||
let git = cfg!(feature = "git") && matches.has(&flags::GIT)?;
|
let git = matches.has(&flags::GIT)?;
|
||||||
|
|
||||||
let blocks = matches.has(&flags::BLOCKS)?;
|
let blocks = matches.has(&flags::BLOCKS)?;
|
||||||
let group = matches.has(&flags::GROUP)?;
|
let group = matches.has(&flags::GROUP)?;
|
||||||
|
|
|
@ -99,7 +99,7 @@ impl Columns {
|
||||||
columns.push(Column::Timestamp(TimeType::Accessed));
|
columns.push(Column::Timestamp(TimeType::Accessed));
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg!(feature = "git") && self.git && actually_enable_git {
|
if self.git && actually_enable_git {
|
||||||
columns.push(Column::GitStatus);
|
columns.push(Column::GitStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user