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

Provide an option in ack to only parse files passed to it. #614

Closed
toddr opened this issue Oct 18, 2016 · 6 comments
Closed

Provide an option in ack to only parse files passed to it. #614

toddr opened this issue Oct 18, 2016 · 6 comments
Labels

Comments

@toddr
Copy link

toddr commented Oct 18, 2016

In my environment, git grep is much faster at file finding than ack. Not to mention I only want to parse the files in the repo.

we have come up with a git alias that does what we want.

grack = "!f() { git grep -l -E $1 | ack -x --flush $* ;}; f"

The problem is that -x and --type are mutually exclusive (see https://github.com/petdance/ack2/issues/607)

My proposal is a -X option that does just tells ack which files it needs to parse explicitly, including deciding if the file type, etc is appropriate.

NOTE: looking at File::Next, it already provides from_file so if you do File::Next:: from_file('-'), This should be all we need to implement -X?

@petdance
Copy link
Collaborator

You would probably do it as a file_filter to the File::Next iterator. But let's talk about behavior rather than implementation.

@petdance
Copy link
Collaborator

What I understand is that you want to be able to do:

cat filelist.txt | ack -X --perl foo

which would only search for foo in files that were identified as Perl, and that came from filelist.txt.

More simply, you would have this:

cat filelist.txt | ack -X --perl -f

which would then only list the files from filelist.txt that satisfy --perl.

Let's try to think of things that could go wrong with that.

@petdance
Copy link
Collaborator

Basically, -X would be -x that respected --type.

@toddr
Copy link
Author

toddr commented Oct 18, 2016

I didn't ask the question. Maybe I should. Other than legacy is there a good reason -x doesn't support --type?

@petdance
Copy link
Collaborator

-x doesn't support --type because -x says "This is the list of files you're going to use." Think of how xargs reads arguments. It says "I'm just going to get stuff from stdin".

@petdance
Copy link
Collaborator

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

No branches or pull requests

2 participants