summaryrefslogtreecommitdiff
path: root/go/src/cow-dedupe/dedupe.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@beefcake.parabola.nu>2018-06-05 12:44:45 -0400
committerLuke Shumaker <lukeshu@beefcake.parabola.nu>2018-06-05 12:44:45 -0400
commit1ff3ecb5b08b40686b0e03cf79c4233c5bf99396 (patch)
tree833b3f6ff19f0b5ae8314a850e9c3b7cc0329540 /go/src/cow-dedupe/dedupe.go
parent8caefed85ae0253a1ea5b95a5a0ad25146b5d6d7 (diff)
fixup statusline
Diffstat (limited to 'go/src/cow-dedupe/dedupe.go')
-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{}