Add --sync option

This commit is contained in:
Junegunn Choi
2015-02-13 12:25:19 +09:00
parent ff09c275d4
commit 6c2ce28d0d
5 changed files with 37 additions and 15 deletions

View File

@@ -110,19 +110,8 @@ func Run(options *Options) {
}
pattern := patternBuilder([]rune(patternString))
looping := true
eventBox.Unwatch(EvtReadNew)
for looping {
eventBox.Wait(func(events *util.Events) {
for evt := range *events {
switch evt {
case EvtReadFin:
looping = false
return
}
}
})
}
eventBox.WaitFor(EvtReadFin)
snapshot, _ := chunkList.Snapshot()
merger, cancelled := matcher.scan(MatchRequest{
@@ -142,6 +131,12 @@ func Run(options *Options) {
}
}
// Synchronous search
if opts.Sync {
eventBox.Unwatch(EvtReadNew)
eventBox.WaitFor(EvtReadFin)
}
// Go interactive
go matcher.Loop()