piranha / goreplace

command line tool for search and replace
ISC License
185 stars 14 forks source link

added a case ware only files confirming to a patern will be searched #11

Closed vigneshsarma closed 11 years ago

vigneshsarma commented 11 years ago

this is in connection with issue #10,

I have very little experience with go code, what do you think?

piranha commented 11 years ago

Hmm... I thought about adding support to actual ignorers, but this is much simpler, I like your approach. I would rename option though, maybe -O/--only? And why name it invIgnorer? Inverted?

vigneshsarma commented 11 years ago

only sounds much better than what I had, changed that,

invIgnore: exactly, because we are using its not value rather than directly using it... Better ideas?

piranha commented 11 years ago

I'm thinking that maybe it's worth it to rename Ignorer's Ignore method to Match, and then searchFiles could accept ignorer and includer. Or no, includer sounds like it would add files... ok, maybe just invertIgnorer then? I have no better ideas.

vigneshsarma commented 11 years ago

Actually Match seems more generic... you could say

if ignoredFiles.Match(name) { 
    return; 
}

if !acceptedFiles.Match(name) {
   return;
}
piranha commented 11 years ago

Exactly, that's what I mean.

vigneshsarma commented 11 years ago

Should I add it to this pull request, or a separate one?

piranha commented 11 years ago

Yeah, add to this one, whole point of renaming to Match is to make this change look nice. :)

vigneshsarma commented 11 years ago

The change in NewGeneralMatcher is so that in the alternate case it shouldn't have to needlessly loop through those patterns. I didn't change that the first time trying to keep the changes to the minimum but, since we are refraction it I thought this would be better.

piranha commented 11 years ago

Well, this is looking seriously good. :) Thanks!