-
-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Listing files only #381
Conversation
src/fs/filter.rs
Outdated
} | ||
(false, true) => { | ||
// On pass -'-only-files' flag only | ||
files.retain(File::is_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a semicolon for consistent formatting. Like this:
files.retain(File::is_file);
@hulxv try running |
src/fs/filter.rs
Outdated
@@ -41,6 +41,9 @@ pub struct FileFilter { | |||
/// Whether to only show directories. | |||
pub only_dirs: bool, | |||
|
|||
/// Whether to only show files. | |||
pub only_files: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to clippy
error: more than 3 bools in a struct
--> src/fs/filter.rs:27:1
|
27 | / pub struct FileFilter {
28 | |
29 | | /// Whether directories should be listed first, and other types of file
30 | | /// second. Some users prefer it like this.
... |
65 | | pub git_ignore: GitIgnore,
66 | | }
| |_^
|
= help: consider using a state machine or refactoring bools into two-variant enums
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#struct_excessive_bools
= note: -D clippy::struct-excessive-bools
implied by -D warnings
error: could not compile eza
(bin "eza") due to previous error
Error: Process completed with exit code 101.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not that big of a problem but I'm not really into rust types so maybe it should be addressed.
But as far as I understand it this can't be done through and enums as clippy suggests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I working on this. some minutes and I will push the solution
I think this is the best way to solve the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/// Whether to only show directories. | ||
pub only_dirs: bool, | ||
// Flags that the file filtering process follow | ||
pub flags: Vec<FileFilterFlags>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice adding a vector and using an enum. Yes I think this is way more elegant then the struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this a nice improvement, and the code looks good. Thanks for also adding a trycmd test.
Could you add completions for:
- zsh
- fish
- bash
Also, you'd have to document your changes in:
- the manpage
man/eza.1.md
- the
README.md
match (self.flags.contains(&OnlyDirs), self.flags.contains(&OnlyFiles)) { | ||
(true, false) => { | ||
// On pass -'-only-dirs' flag only | ||
files.retain(File::is_directory); | ||
} | ||
(false, true) => { | ||
// On pass -'-only-files' flag only | ||
files.retain(File::is_file); | ||
} | ||
_ => {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing it like this means that -f --only-dirs
falls through and doesn't just show no files. It's probably the best solution, because -f --only-dirs
is completely useless if it didn't show anything.
I'm not familiar with bash. I read completions/bash/eza but I didn't understand what I should do to add completion for |
Honestly, it is fine if you don't wanna do the bash completions, few if any here know how to do them and they're horribly out of date anyways. With no bash users as contributors we can skip it tbh. |
I'm an unfortunate bash user (historical reasons), I'll try to go through all the completions and make a PR to fix them all at some point. Edit: #400 |
Ohh, well, thanks for looking into it! You're both the designated windows and bash guy now :p |
Is all done or is there still anything should I do? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is all done or is there still anything should I do?
Nope, seems good to me. Tested sandboxed integrations tests, tested behavior locally, tested completions still work for zsh
and fish
. Also checked man page generation still works and looks good.
Thanks for the contribution, merging in a moment 👍
This PR hasn't merged yet. Is there any problem? |
Yes... I forgot it. Thanks for pinging me >_< |
What's new?
Add '-f' and '--only-files' flag to list files only (like '-D' and '--only-dirs' to list dirs only)
Example:
content
usage
$ eza --only-files -1 hello.rs bye.rs todo.txt README.md
Close #367