Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
solidiquis committed Feb 13, 2023
1 parent 473f5a9 commit 4753186
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
7 changes: 3 additions & 4 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct Clargs {
glob_case_insensitive: bool,

/// Show hidden files; disabled by default
#[arg(short ='H', long)]
#[arg(short = 'H', long)]
pub hidden: bool,

/// Ignore .gitignore; disabled by default
Expand Down Expand Up @@ -112,8 +112,7 @@ impl TryFrom<&Clargs> for WalkParallel {
fn try_from(clargs: &Clargs) -> Result<Self, Self::Error> {
let root = clargs.dir();

fs::metadata(root)
.map_err(|e| Error::DirNotFound(format!("{}: {e}", root.display())))?;
fs::metadata(root).map_err(|e| Error::DirNotFound(format!("{}: {e}", root.display())))?;

Ok(WalkBuilder::new(root)
.follow_links(clargs.follow_links)
Expand All @@ -129,7 +128,7 @@ impl TryFrom<&Clargs> for WalkParallel {
#[derive(Debug)]
pub enum Error {
InvalidGlobPatterns(ignore::Error),
DirNotFound(String)
DirNotFound(String),
}

impl Display for Error {
Expand Down
12 changes: 5 additions & 7 deletions src/fs/erdtree/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ impl Tree {
pub fn new(walker: WalkParallel, order: Order, level: Option<usize>) -> TreeResult<Self> {
let root = Self::traverse(walker, &order)?;

Ok(Self {
level,
order,
root,
})
Ok(Self { level, order, root })
}

/// Returns a reference to the root [Node].
Expand Down Expand Up @@ -159,7 +155,7 @@ impl Display for Tree {
children: Iter<Node>,
base_prefix: &str,
level: usize,
theme: &ui::ThemesMap
theme: &ui::ThemesMap,
) {
let mut peekable = children.peekable();

Expand All @@ -184,7 +180,9 @@ impl Display for Tree {
if let Some(iter_children) = child.children() {
let mut new_base = base_prefix.to_owned();

let new_theme = child.symlink.then(|| ui::get_link_theme()).unwrap_or(theme);
let new_theme = child.symlink
.then(|| ui::get_link_theme())
.unwrap_or(theme);

if last_entry {
new_base.push_str(ui::SEP);
Expand Down
4 changes: 2 additions & 2 deletions src/fs/erdtree/tree/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pub static LS_COLORS: OnceCell<LsColors> = OnceCell::new();

/// Runtime evaluated static that contains ANSI-colored box drawing characters used for the
/// printing of [super::Tree]'s branches.
pub static THEME: OnceCell<ThemesMap> = OnceCell::new();
pub static THEME: OnceCell<ThemesMap> = OnceCell::new();

/// Runtime evaluated static that contains ANSI-colored box drawing characters used for the
/// printing of [super::Tree]'s branches for descdendents of symlinks.
pub static LINK_THEME: OnceCell<ThemesMap> = OnceCell::new();
pub static LINK_THEME: OnceCell<ThemesMap> = OnceCell::new();

/// Map of the names box-drawing elements to their styled strings.
pub type ThemesMap = HashMap<&'static str, String>;
Expand Down
9 changes: 8 additions & 1 deletion tests/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ fn glob_negative() {
#[test]
fn glob_case_insensitive() {
assert_eq!(
utils::run_cmd(&["--sort", "name", "--glob", "*.TXT", "--glob-case-insensitive", "tests/data"]),
utils::run_cmd(&[
"--sort",
"name",
"--glob",
"*.TXT",
"--glob-case-insensitive",
"tests/data"
]),
indoc!(
"
data (652.00 B)
Expand Down
4 changes: 3 additions & 1 deletion tests/symlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ mod test {

symlink(target, &link)?;

let link_canonical = link.canonicalize().map(|c| c.to_string_lossy().into_owned())?;
let link_canonical = link
.canonicalize()
.map(|c| c.to_string_lossy().into_owned())?;

assert_eq!(
super::utils::run_cmd(&["--sort", "name", "--follow-links", &link_canonical]),
Expand Down
6 changes: 1 addition & 5 deletions tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ use strip_ansi_escapes::strip as strip_ansi_escapes;

pub fn run_cmd(args: &[&str]) -> String {
let mut cmd = Command::new("cargo");
cmd.arg("run")
.arg("--")
.arg("--threads")
.arg("1");
cmd.arg("run").arg("--").arg("--threads").arg("1");

for arg in args {
cmd.arg(arg);
Expand All @@ -28,4 +25,3 @@ pub fn run_cmd(args: &[&str]) -> String {
.trim()
.to_string()
}

0 comments on commit 4753186

Please sign in to comment.