Skip to content

Commit d8eaecd

Browse files
hemreariPeltoche
authored andcommitted
add almost-all flag
1 parent 4485087 commit d8eaecd

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/app.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ pub fn build() -> App<'static, 'static> {
1515
.arg(
1616
Arg::with_name("almost-all")
1717
.short("A")
18+
.long("almost-all")
1819
.multiple(true)
19-
.help("Alias of -a"),
20+
.help("Do not list implied . and .."),
2021
)
2122
.arg(
2223
Arg::with_name("color")

src/core.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,19 @@ impl Core {
6767
};
6868

6969
for path in paths {
70-
let absolute_path = match fs::canonicalize(&path) {
71-
Ok(path) => path,
72-
Err(err) => {
73-
println!("couldn't access '{}': {}", path.display(), err);
74-
continue;
75-
}
76-
};
70+
let absolute_path = match fs::canonicalize(&path) {
71+
Ok(path) => path,
72+
Err(err) => {
73+
println!("couldn't access '{}': {}", path.display(), err);
74+
continue;
75+
}
76+
};
7777

7878
match Meta::from_path_recursive(
7979
&fs::canonicalize(&absolute_path.to_path_buf()).unwrap(),
8080
depth,
8181
self.flags.display_all,
82+
self.flags.display_almost_all,
8283
) {
8384
Ok(meta) => meta_list.push(meta),
8485
Err(err) => println!("cannot access '{}': {}", path.display(), err),

src/meta/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ impl Meta {
4040
path: &PathBuf,
4141
depth: usize,
4242
list_hidden_files: bool,
43+
list_almost_all: bool,
4344
) -> Result<Self, std::io::Error> {
4445
let mut meta = Self::from_path(path)?;
4546

@@ -81,6 +82,7 @@ impl Meta {
8182
let path = entry?.path();
8283

8384
if !list_hidden_files
85+
&& !list_almost_all
8486
&& path
8587
.file_name()
8688
.ok_or_else(|| Error::new(ErrorKind::InvalidInput, "invalid file name"))?
@@ -94,6 +96,7 @@ impl Meta {
9496
&path.to_path_buf(),
9597
depth - 1,
9698
list_hidden_files,
99+
list_almost_all,
97100
) {
98101
Ok(res) => res,
99102
Err(err) => {

0 commit comments

Comments
 (0)