summaryrefslogtreecommitdiff
path: root/go/src/cow-dedupe
diff options
context:
space:
mode:
Diffstat (limited to 'go/src/cow-dedupe')
-rw-r--r--go/src/cow-dedupe/dedupe.go39
1 files changed, 31 insertions, 8 deletions
diff --git a/go/src/cow-dedupe/dedupe.go b/go/src/cow-dedupe/dedupe.go
index 4913f3d..0c40d4a 100644
--- a/go/src/cow-dedupe/dedupe.go
+++ b/go/src/cow-dedupe/dedupe.go
@@ -27,22 +27,40 @@ func errhandle(err error) {
}
}
-func myStatusLine() statusline.StatusLine {
- var outs []statusline.StatusLine
+var myStatusLine = func() func() statusline.StatusLine {
+ var outs []func() statusline.StatusLine
if C.isatty(2) != 0 {
- outs = append(outs, statusline.StopWatch(statusline.RateLimit(statusline.New(os.Stderr), time.Second/2), time.Second))
+ fmt.Println("Output: TTY")
+ outs = append(outs, func() statusline.StatusLine {
+ return statusline.StopWatch(statusline.RateLimit(statusline.TTY(os.Stderr), time.Second/2), time.Second)
+ })
}
if os.Getenv("NOTIFY_SOCKET") != "" {
- outs = append(outs, statusline.RateLimit(statusline.DaemonStatus(0), time.Second/2))
+ fmt.Println("Output: SD")
+ outs = append(outs, func() statusline.StatusLine {
+ return statusline.RateLimit(statusline.DaemonStatus(0), time.Second/2)
+ })
+ outs = append(outs, func() statusline.StatusLine {
+ return statusline.RateLimit(statusline.Log(os.Stderr), time.Minute)
+ })
}
if len(outs) == 0 {
- outs = append(outs, statusline.New(os.Stderr))
+ fmt.Println("Output: ERR")
+ outs = append(outs, func() statusline.StatusLine {
+ return statusline.Log(os.Stderr)
+ })
}
if len(outs) == 1 {
return outs[0]
}
- return statusline.Tee(outs...)
-}
+ return func() statusline.StatusLine {
+ var sls []statusline.StatusLine
+ for _, fn := range outs {
+ sls = append(sls, fn())
+ }
+ return statusline.Tee(sls...)
+ }
+}()
func getFiemaps(paths []string) map[string][]string {
var err error
@@ -216,7 +234,12 @@ func main() {
fiemap2filenames := getFiemaps(os.Args[1:])
- sl := statusline.StopWatch(statusline.New(os.Stderr), time.Second)
+ var sl statusline.StatusLine
+ if C.isatty(2) != 0 {
+ sl = statusline.StopWatch(statusline.TTY(os.Stderr), time.Second)
+ } else {
+ sl = statusline.Log(os.Stderr)
+ }
sl.Put("Building list of spanning files...")
filename2fiemap := map[string]string{}