mirror of
https://github.com/eza-community/eza.git
synced 2025-08-04 17:08:42 +00:00
feat(git): adding the EZA_OVERRIDE_GIT env var
This var will override any --git or --git-repos
This commit is contained in:
parent
143f37a7eb
commit
bad3f1a615
3 changed files with 19 additions and 5 deletions
|
@ -274,6 +274,10 @@ Specifies the colour scheme used to highlight files based on their name and kind
|
|||
|
||||
For more information on the format of these environment variables, see the [eza_colors.5.md](eza_colors.5.md) manual page.
|
||||
|
||||
## `EZA_OVERRIDE_GIT`
|
||||
|
||||
Overrides any `--git` or `--git-repos` argument
|
||||
|
||||
|
||||
EXIT STATUSES
|
||||
=============
|
||||
|
|
|
@ -52,6 +52,9 @@ pub static EZA_GRID_ROWS: &str = "EZA_GRID_ROWS";
|
|||
pub static EXA_ICON_SPACING: &str = "EXA_ICON_SPACING";
|
||||
pub static EZA_ICON_SPACING: &str = "EZA_ICON_SPACING";
|
||||
|
||||
pub static EXA_OVERRIDE_GIT: &str = "EXA_OVERRIDE_GIT";
|
||||
pub static EZA_OVERRIDE_GIT: &str = "EZA_OVERRIDE_GIT";
|
||||
|
||||
/// Mockable wrapper for `std::env::var_os`.
|
||||
pub trait Vars {
|
||||
fn get(&self, name: &'static str) -> Option<OsString>;
|
||||
|
|
|
@ -231,7 +231,7 @@ impl TableOptions {
|
|||
let time_format = TimeFormat::deduce(matches, vars)?;
|
||||
let size_format = SizeFormat::deduce(matches)?;
|
||||
let user_format = UserFormat::deduce(matches)?;
|
||||
let columns = Columns::deduce(matches)?;
|
||||
let columns = Columns::deduce(matches, vars)?;
|
||||
Ok(Self {
|
||||
size_format,
|
||||
time_format,
|
||||
|
@ -242,14 +242,21 @@ impl TableOptions {
|
|||
}
|
||||
|
||||
impl Columns {
|
||||
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
|
||||
fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
|
||||
use crate::options::vars;
|
||||
let time_types = TimeTypes::deduce(matches)?;
|
||||
|
||||
let git = matches.has(&flags::GIT)? && !matches.has(&flags::NO_GIT)?;
|
||||
let subdir_git_repos = matches.has(&flags::GIT_REPOS)? && !matches.has(&flags::NO_GIT)?;
|
||||
let no_git_env = vars
|
||||
.get_with_fallback(vars::EXA_OVERRIDE_GIT, vars::EZA_OVERRIDE_GIT)
|
||||
.is_some();
|
||||
|
||||
let git = matches.has(&flags::GIT)? && !matches.has(&flags::NO_GIT)? && !no_git_env;
|
||||
let subdir_git_repos =
|
||||
matches.has(&flags::GIT_REPOS)? && !matches.has(&flags::NO_GIT)? && !no_git_env;
|
||||
let subdir_git_repos_no_stat = !subdir_git_repos
|
||||
&& matches.has(&flags::GIT_REPOS_NO_STAT)?
|
||||
&& !matches.has(&flags::NO_GIT)?;
|
||||
&& !matches.has(&flags::NO_GIT)?
|
||||
&& !no_git_env;
|
||||
|
||||
let blocksize = matches.has(&flags::BLOCKSIZE)?;
|
||||
let group = matches.has(&flags::GROUP)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue