mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-09-27 12:49:01 +00:00
51be9f4c43
This commit remove the extra space that was added between icons and file names in commit 128fadd
, and adds an option to put them back.
Re-fixes GH-619 and fixes GH-541.
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
use crate::options::{flags, OptionsError};
|
|
use crate::options::parser::MatchedFlags;
|
|
use crate::options::vars::{self, Vars};
|
|
|
|
use crate::output::file_name::{Options, Classify, ShowIcons};
|
|
|
|
|
|
impl Options {
|
|
pub fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
|
|
let classify = Classify::deduce(matches)?;
|
|
let show_icons = ShowIcons::deduce(matches, vars)?;
|
|
|
|
Ok(Self { classify, show_icons })
|
|
}
|
|
}
|
|
|
|
impl Classify {
|
|
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
|
|
let flagged = matches.has(&flags::CLASSIFY)?;
|
|
|
|
if flagged { Ok(Self::AddFileIndicators) }
|
|
else { Ok(Self::JustFilenames) }
|
|
}
|
|
}
|
|
|
|
impl ShowIcons {
|
|
pub fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
|
|
if ! matches.has(&flags::ICONS)? {
|
|
Ok(Self::Off)
|
|
}
|
|
else if let Some(columns) = vars.get(vars::EXA_ICON_SPACING).and_then(|s| s.into_string().ok()) {
|
|
match columns.parse() {
|
|
Ok(width) => Ok(Self::On(width)),
|
|
Err(e) => Err(OptionsError::FailedParse(e)),
|
|
}
|
|
}
|
|
else {
|
|
Ok(Self::On(1))
|
|
}
|
|
}
|
|
}
|