From 8f11c67956cf84a87fe80a40d8a38b8f538b87c6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 10 Nov 2015 01:58:06 -0800 Subject: [PATCH] diff: Add scanBar for recursive diff --- diff-main.go | 11 +++++++++++ diff.go | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/diff-main.go b/diff-main.go index 46449f25..f6a7a85a 100644 --- a/diff-main.go +++ b/diff-main.go @@ -97,9 +97,20 @@ func mainDiff(ctx *cli.Context) { newFirstURL := stripRecursiveURL(firstURL) for diff := range doDiffMain(newFirstURL, secondURL, isURLRecursive(firstURL)) { + if diff.Error != nil { + // Print in new line and adjust to top so that we don't print over the ongoing scan bar + if !globalQuietFlag && !globalJSONFlag { + console.Eraseline() + } + } fatalIf(diff.Error.Trace(newFirstURL, secondURL), "Failed to diff ‘"+firstURL+"’ and ‘"+secondURL+"’.") printMsg(diff) } + // Print in new line and adjust to top so that we don't print over the ongoing scan bar + if !globalQuietFlag && !globalJSONFlag { + console.Eraseline() + } + console.Println(console.Colorize("DiffMessage", "Done.")) } // doDiffMain runs the diff. diff --git a/diff.go b/diff.go index 9c99a83d..9906e447 100644 --- a/diff.go +++ b/diff.go @@ -169,6 +169,10 @@ func diffFolders(firstClnt, secondClnt client.Client, outCh chan<- diffMessage) // // 4: diff(d1..., d2) -> []diff(d1/f, d2/f) -> VALID. func diffFoldersRecursive(firstClnt, secondClnt client.Client, outCh chan<- diffMessage) { + var scanBar scanBarFunc + if !globalQuietFlag && !globalJSONFlag { // set up progress bar + scanBar = scanBarFactory() + } recursive := true firstListCh := firstClnt.List(recursive, false) // Copy first list channel. for firstContentCh := range firstListCh { @@ -197,5 +201,8 @@ func diffFoldersRecursive(firstClnt, secondClnt client.Client, outCh chan<- diff outCh <- *diffMsg continue } + if !globalQuietFlag && !globalJSONFlag { // set up progress bar + scanBar(firstContent.URL.String()) + } } }