-
Notifications
You must be signed in to change notification settings - Fork 20
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
proposal: CLI for tree-grepper 3.0 #436
Comments
Since it's desirable to drop the
While both suggestions have a downside of being somewhat quirky and unusual, they would both work even if one of the search paths is also named |
I could have been clearer! The proposal moves away from using tree-sitter LANG QUERY [PATH..] So if you have a directory named tree-sitter elm '(import_statement)' elm It's already unambiguous positionally; no extra syntax required. |
Ah, gotcha, so you're pivoting towards having only a single query string, right? I was trying to come up with something that would still allow any number of queries and paths. But I haven't used tree-grepper much yet, so not sure if that's very useful in practice :-) |
I added it because I found it useful in one place, but it's just more noise and complexity in almost every other place. Scanning the filesystem is generally doesn't have as much overhead as I was planning for, so running |
I think you could just string concat your queries instead of having to specify multiple times if you really need the feature. |
Yes, and in fact that’s what tree-grepper does internally. But before you could load multiple languages in an invocation. That’s what’s going away. |
Right now we have a conflict (#355) between single files and additional queries which means that queries cannot be run against single files.
To be honest, I've only ever needed additional queries in one situation, and in that situation it would have been fine to make two calls. (One each for Elm and JavaScript.)
I'd like to change the CLI to something like this (each line is an invocation, using Elm as an example):
Multiple roots and files can also be specified and/or combined. This gets rid of the
-q
/--query
flag, which would let us maketree-grepper
faster by only loading a single language at a time.I'd also like to refine the differences between
--format
and--show-tree
. There are a couple possibilities for this:tree
becomes an output for--format
. Consistent, but needstree-grepper elm "(.)" --format tree some/File.elm
.--show-tree
and--format
conflict—tree view is a different mode specified by a flag.--show-tree
outputs a tree in json format if--format=json
--show-tree
moves to a separate binary liketree-grepper-show-tree
I like the first option best, even though it's a little more typing, since it would let us show the trees for individual matches as well as entire files.
I'm going to let this sit for a while before implementing it. If you've got ideas, chime in!
The text was updated successfully, but these errors were encountered: