mirror of
https://github.com/lsd-rs/lsd
synced 2025-03-04 23:17:15 +00:00
use existing display and layout
This commit is contained in:
parent
42c3c8ca62
commit
1cdef5fe96
4 changed files with 23 additions and 34 deletions
|
@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Add support for `--extensionsort` `-X` from [aldhsu](https://github.com/aldhsu)
|
- Add support for `--extensionsort` `-X` from [aldhsu](https://github.com/aldhsu)
|
||||||
- Add support for `--versionsort` `-v` from [zwpaper](https://github.com/zwpaper)
|
- Add support for `--versionsort` `-v` from [zwpaper](https://github.com/zwpaper)
|
||||||
- Add support for config symlink arrow from [zwpaper](https://github.com/zwpaper) [#409](https://github.com/Peltoche/lsd/issues/409)
|
- Add support for config symlink arrow from [zwpaper](https://github.com/zwpaper) [#409](https://github.com/Peltoche/lsd/issues/409)
|
||||||
- Implement `--tree -d`, analogous to `tree -d` from [0jdxt](https://github.com/0jdxt)
|
- Implement `--tree -d`, analogous to `tree -d` from [0jdxt](https://github.com/0jdxt) and [Utah Rust](https://github.com/utah-rust)
|
||||||
### Changed
|
### Changed
|
||||||
- Use last sort flag for sort field from [meain](https://github.com/meain)
|
- Use last sort flag for sort field from [meain](https://github.com/meain)
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
31
src/core.rs
31
src/core.rs
|
@ -94,22 +94,21 @@ impl Core {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match self.flags.display {
|
let recurse =
|
||||||
Display::DirectoryItself => {
|
self.flags.layout == Layout::Tree || self.flags.display != Display::DirectoryItself;
|
||||||
meta_list.push(meta);
|
if recurse {
|
||||||
}
|
match meta.recurse_into(depth, &self.flags) {
|
||||||
_ => {
|
Ok(content) => {
|
||||||
match meta.recurse_into(depth, &self.flags) {
|
meta.content = content;
|
||||||
Ok(content) => {
|
meta_list.push(meta);
|
||||||
meta.content = content;
|
}
|
||||||
meta_list.push(meta);
|
Err(err) => {
|
||||||
}
|
print_error!("lsd: {}: {}\n", path.display(), err);
|
||||||
Err(err) => {
|
continue;
|
||||||
print_error!("lsd: {}: {}\n", path.display(), err);
|
}
|
||||||
continue;
|
};
|
||||||
}
|
} else {
|
||||||
};
|
meta_list.push(meta);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if self.flags.total_size.0 {
|
if self.flags.total_size.0 {
|
||||||
|
|
|
@ -15,7 +15,6 @@ pub enum Display {
|
||||||
AlmostAll,
|
AlmostAll,
|
||||||
DirectoryItself,
|
DirectoryItself,
|
||||||
DisplayOnlyVisible,
|
DisplayOnlyVisible,
|
||||||
TreeD,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display {
|
impl Display {
|
||||||
|
@ -46,11 +45,7 @@ impl Configurable<Self> for Display {
|
||||||
} else if matches.is_present("almost-all") {
|
} else if matches.is_present("almost-all") {
|
||||||
Some(Self::AlmostAll)
|
Some(Self::AlmostAll)
|
||||||
} else if matches.is_present("directory-only") {
|
} else if matches.is_present("directory-only") {
|
||||||
if matches.is_present("tree") {
|
Some(Self::DirectoryItself)
|
||||||
Some(Self::TreeD)
|
|
||||||
} else {
|
|
||||||
Some(Self::DirectoryItself)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -128,13 +123,6 @@ mod test {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_from_arg_matches_display_only_directories() {
|
|
||||||
let argv = vec!["lsd", "--tree", "-d"];
|
|
||||||
let matches = app::build().get_matches_from_safe(argv).unwrap();
|
|
||||||
assert_eq!(Some(Display::TreeD), Display::from_arg_matches(&matches));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_config_none() {
|
fn test_from_config_none() {
|
||||||
assert_eq!(None, Display::from_config(&Config::with_none()));
|
assert_eq!(None, Display::from_config(&Config::with_none()));
|
||||||
|
|
|
@ -54,7 +54,7 @@ impl Meta {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.display == Display::DirectoryItself {
|
if flags.display == Display::DirectoryItself && flags.layout != Layout::Tree {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,9 +118,11 @@ impl Meta {
|
||||||
};
|
};
|
||||||
|
|
||||||
// skip files for --tree -d
|
// skip files for --tree -d
|
||||||
if let Display::TreeD = flags.display {
|
if flags.layout == Layout::Tree {
|
||||||
if !entry.file_type()?.is_dir() {
|
if let Display::DirectoryItself = flags.display {
|
||||||
continue;
|
if !entry.file_type()?.is_dir() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue