Skip to content

Commit

Permalink
Remove GitTheme
Browse files Browse the repository at this point in the history
  • Loading branch information
hpwxf committed Apr 30, 2023
1 parent fe9986e commit 9c7476d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 173 deletions.
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,6 @@ symlink-arrow: ⇒
# Whether to display block headers.
# Possible values: false, true
header: false

# == Git ==
git:
# Whether to display git status
# Possible values: false, true
enabled: false
# How to display git status
# When "classic" is set, this is set to "default".
# Possible values: default, <theme-file-name>
# when specifying <theme-file-name>, lsd will look up theme file
# XDG Base Directory if relative, e.g. ~/.config/lsd/themes/<theme-file-name>.yaml,
# The file path if absolute
theme: default
```
</details>
Expand Down
16 changes: 2 additions & 14 deletions src/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::flags::layout::Layout;
use crate::flags::permission::PermissionFlag;
use crate::flags::size::SizeFlag;
use crate::flags::sorting::{DirGrouping, SortColumn};
use crate::flags::HyperlinkOption;
use crate::flags::{ColorOption, ThemeOption};
use crate::flags::{GitTheme, HyperlinkOption};
///! This module provides methods to handle the program's config files and operations related to
///! this.
use crate::print_error;
Expand Down Expand Up @@ -45,7 +45,6 @@ pub struct Config {
pub symlink_arrow: Option<String>,
pub hyperlink: Option<HyperlinkOption>,
pub header: Option<bool>,
pub git_theme: Option<GitTheme>,
}

#[derive(Eq, PartialEq, Debug, Deserialize)]
Expand Down Expand Up @@ -98,7 +97,6 @@ impl Config {
symlink_arrow: None,
hyperlink: None,
header: None,
git_theme: None,
}
}

Expand Down Expand Up @@ -325,15 +323,6 @@ hyperlink: never
# == Symlink arrow ==
# Specifies how the symlink arrow display, chars in both ascii and utf8
symlink-arrow: ⇒
# == Git ==
# How to display git status
# When "classic" is set, this is set to "default".
# Possible values: default, <theme-file-name>
# when specifying <theme-file-name>, lsd will look up theme file
# XDG Base Directory if relative, e.g. ~/.config/lsd/themes/<theme-file-name>.yaml,
# The file path if absolute
git-theme: default
"#;

#[cfg(test)]
Expand All @@ -353,7 +342,7 @@ mod tests {
use crate::flags::permission::PermissionFlag;
use crate::flags::size::SizeFlag;
use crate::flags::sorting::{DirGrouping, SortColumn};
use crate::flags::{GitTheme, HyperlinkOption};
use crate::flags::HyperlinkOption;

#[test]
fn test_read_default() {
Expand Down Expand Up @@ -400,7 +389,6 @@ mod tests {
symlink_arrow: Some("⇒".into()),
hyperlink: Some(HyperlinkOption::Never),
header: None,
git_theme: Some(GitTheme::Default)
},
c
);
Expand Down
3 changes: 1 addition & 2 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ impl Core {

let icon_when = flags.icons.when;
let icon_theme = flags.icons.theme.clone();
let git_theme = flags.git_theme.clone();

// TODO: Rework this so that flags passed downstream does not
// have Auto option for any (icon, color, hyperlink).
Expand Down Expand Up @@ -81,7 +80,7 @@ impl Core {
flags,
colors: Colors::new(color_theme),
icons: Icons::new(tty_available, icon_when, icon_theme, icon_separator),
git_theme: GitTheme::new(git_theme),
git_theme: GitTheme::new(),
sorters,
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,7 @@ mod tests {
use crate::app::Cli;
use crate::color;
use crate::color::Colors;
use crate::flags::{
GitTheme as GitFlagTheme, HyperlinkOption, IconOption, IconTheme as FlagTheme,
};
use crate::flags::{HyperlinkOption, IconOption, IconTheme as FlagTheme};
use crate::icon::Icons;
use crate::meta::{FileType, Name};
use crate::Config;
Expand Down Expand Up @@ -697,7 +695,7 @@ mod tests {
&flags,
&Colors::new(color::ThemeOption::NoColor),
&Icons::new(false, IconOption::Never, FlagTheme::Fancy, " ".to_string()),
&GitTheme::new(GitFlagTheme::Default),
&GitTheme::new(),
);

assert_eq!("one.d\n├── .hidden\n└── two\n", output);
Expand Down Expand Up @@ -729,7 +727,7 @@ mod tests {
&flags,
&Colors::new(color::ThemeOption::NoColor),
&Icons::new(false, IconOption::Never, FlagTheme::Fancy, " ".to_string()),
&GitTheme::new(GitFlagTheme::Default),
&GitTheme::new(),
);

let length_before_b = |i| -> usize {
Expand Down Expand Up @@ -770,7 +768,7 @@ mod tests {
&flags,
&Colors::new(color::ThemeOption::NoColor),
&Icons::new(false, IconOption::Never, FlagTheme::Fancy, " ".to_string()),
&GitTheme::new(GitFlagTheme::Default),
&GitTheme::new(),
);

assert_eq!(output.lines().nth(1).unwrap().chars().next().unwrap(), '└');
Expand Down Expand Up @@ -810,7 +808,7 @@ mod tests {
&flags,
&Colors::new(color::ThemeOption::NoColor),
&Icons::new(false, IconOption::Never, FlagTheme::Fancy, " ".to_string()),
&GitTheme::new(GitFlagTheme::Default),
&GitTheme::new(),
);

assert!(output.ends_with("└── two\n"));
Expand Down Expand Up @@ -841,7 +839,7 @@ mod tests {
&flags,
&Colors::new(color::ThemeOption::NoColor),
&Icons::new(false, IconOption::Never, FlagTheme::Fancy, " ".to_string()),
&GitTheme::new(GitFlagTheme::Default),
&GitTheme::new(),
);

dir.close().unwrap();
Expand Down Expand Up @@ -875,7 +873,7 @@ mod tests {
&flags,
&Colors::new(color::ThemeOption::NoColor),
&Icons::new(false, IconOption::Never, FlagTheme::Fancy, " ".to_string()),
&GitTheme::new(GitFlagTheme::Default),
&GitTheme::new(),
);

dir.close().unwrap();
Expand Down
4 changes: 0 additions & 4 deletions src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub mod color;
pub mod date;
pub mod dereference;
pub mod display;
pub mod git_theme;
pub mod header;
pub mod hyperlink;
pub mod icons;
Expand All @@ -24,7 +23,6 @@ pub use color::{ColorOption, ThemeOption};
pub use date::DateFlag;
pub use dereference::Dereference;
pub use display::Display;
pub use git_theme::GitTheme;
pub use header::Header;
pub use hyperlink::HyperlinkOption;
pub use icons::IconOption;
Expand Down Expand Up @@ -74,7 +72,6 @@ pub struct Flags {
pub symlink_arrow: SymlinkArrow,
pub hyperlink: HyperlinkOption,
pub header: Header,
pub git_theme: GitTheme,
pub should_quote: bool,
}

Expand Down Expand Up @@ -105,7 +102,6 @@ impl Flags {
symlink_arrow: SymlinkArrow::configure_from(cli, config),
hyperlink: HyperlinkOption::configure_from(cli, config),
header: Header::configure_from(cli, config),
git_theme: GitTheme::configure_from(cli, config),
should_quote: true,
})
}
Expand Down
119 changes: 0 additions & 119 deletions src/flags/git_theme.rs

This file was deleted.

14 changes: 2 additions & 12 deletions src/git_theme.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
use crate::flags::GitTheme as GitFlagTheme;
use crate::git::GitStatus;
use crate::theme::git::GitThemeSymbols;
use crate::theme::Theme;
use std::path::Path;

pub struct GitTheme {
symbols: GitThemeSymbols,
}

impl GitTheme {
pub fn new(theme: GitFlagTheme) -> GitTheme {
let git_symbols = match theme {
GitFlagTheme::Default => GitThemeSymbols::default(),
GitFlagTheme::Custom(ref file) => Theme::from_path::<GitThemeSymbols>(
Path::new("themes").join(file).to_str().unwrap_or(file),
)
.unwrap_or_default(),
};

pub fn new() -> GitTheme {
let git_symbols = GitThemeSymbols::default();
Self {
symbols: git_symbols,
}
Expand Down

0 comments on commit 9c7476d

Please sign in to comment.