Skip to content
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

Idea: orthogonal specification of patterns and paths #889

Closed
grothesque opened this issue Nov 19, 2021 · 3 comments
Closed

Idea: orthogonal specification of patterns and paths #889

grothesque opened this issue Nov 19, 2021 · 3 comments

Comments

@grothesque
Copy link

Thanks for creating this very useful alternative to classic find!

Here, I suggest an improvement to the user interface that would make it both simpler and more powerful.

(This idea requires breaking backwards compatibility, but I believe that this would pay off. There are different ways in which such a backward-incompatible change could be realized without surprising current users, so please bear with me.)

I suggest that search paths be provided as a command line option (for example -r --root) and no longer as command line arguments that follow the pattern. Thus, any non-option command line arguments would be search patterns. This would allow providing zero, one or an arbitrary number of search patterns. If more than one search pattern was provided, these would be combined using logical AND.

This change would have the following advantages:

  • Currently it is possible to provide no search path and no search patterns (e.g. fd -ejpg), but it is not possible to provide a path without a pattern. This use case would become possible, e.g. fd -ejpg -rsubdir.

  • Currently there is a way to realize logical OR in patterns. Logical AND would be very useful as well (for example for searching for file names that contain both "foo" and "bar" in any order - see Finding multiple patterns #315), but there is no easy way to express it. Having multiple patterns would provide an intuitive syntax.

@tavianator
Copy link
Collaborator

There is already --search-path which seems to do what you want from --root. I doubt we would support multiple patterns that way though, it would be extremely breaking.

@grothesque
Copy link
Author

grothesque commented Nov 19, 2021

Indeed, --search-path does what I meant for --root. Unfortunately, both -s and -p are taken, that's why I proposed -r and --root.

I believe that allowing multiple patterns would be a huge improvement to the command line interface, making it worthwhile to consider the backwards incompatible change. In order not to surprise current users, the change could be introduced in one of the following ways:

  • Allow specification of additional patterns through --and. Deprecate and eventually forbid specification of paths as args. After a cool down period additional non-option args could gain the new meaning of --and.
  • Provide a fd2 command with the new behavior. Deprecate and eventually remove fd. After some time, fd2 could be aliased to fd. (if it works for python3, it should work for fd. This could be an occasion to fix other possible UI problems.)

@tmccombs
Copy link
Collaborator

tmccombs commented Nov 20, 2021

I'm going to close this as a duplicate of #315 because --search-path already provides the functionality of the proposed --root, #315 is already about supporting AND for multiple patterns. Let me know if you think it should remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants