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