Skip to content

Adds a stream mode option #24

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func main() {
var dumpMode bool
flag.BoolVar(&dumpMode, "dump", false, "prints the grep command rather than executing it")

var streamMode bool
flag.BoolVar(&streamMode, "stream", false, "sets gf in stream mode")

flag.Parse()

if listMode {
Expand Down Expand Up @@ -92,6 +95,12 @@ func main() {
pat.Pattern = "(" + strings.Join(pat.Patterns, "|") + ")"
}

if streamMode {
// for stream mode, remove the recursive flag ("r") and filename ("H") which is always stdin
pat.Flags = strings.Replace(pat.Flags,"r","", -1)
pat.Flags = strings.Replace(pat.Flags,"H","", -1)
}

if dumpMode {
fmt.Printf( "grep --color %v %q %v\n", pat.Flags, pat.Pattern, files )
//fmt.Println( "grep --color", pat.Flags, pat.Pattern, files)
Expand Down