From 0d09189e4a6e1bad682e8972edd93ddaacf47cf6 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Tue, 2 Jun 2015 20:01:27 +0100 Subject: [PATCH] Make copying command more informative especially with several source files --- cmd-cp.go | 3 +++ cp-bar.go | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/cmd-cp.go b/cmd-cp.go index c869cd89..4a58e3c1 100644 --- a/cmd-cp.go +++ b/cmd-cp.go @@ -69,6 +69,9 @@ EXAMPLES: // doCopy - Copy a singe file from source to destination func doCopy(sourceURL string, sourceConfig *hostConfig, targetURL string, targetConfig *hostConfig, bar *barSend) error { + if !globalQuietFlag { + bar.SetPrefix(sourceURL + ": ") + } reader, length, err := getSource(sourceURL, sourceConfig) if err != nil { if !globalQuietFlag { diff --git a/cp-bar.go b/cp-bar.go index 984c428a..c38d2e52 100644 --- a/cp-bar.go +++ b/cp-bar.go @@ -33,6 +33,7 @@ const ( cpBarCmdFinish cpBarCmdPutError cpBarCmdGetError + cpBarCmdSetPrefix ) type copyReader struct { @@ -76,6 +77,10 @@ func (b *barSend) NewProxyReader(r io.Reader) *copyReader { return ©Reader{r, b} } +func (b *barSend) SetPrefix(prefix string) { + b.cmdCh <- barMsg{Cmd: cpBarCmdSetPrefix, Arg: prefix} +} + func (b barSend) Finish() { defer close(b.cmdCh) b.cmdCh <- barMsg{Cmd: cpBarCmdFinish} @@ -102,6 +107,8 @@ func newCpBar() barSend { bar.Format("[=> ]") for msg := range cmdCh { switch msg.Cmd { + case cpBarCmdSetPrefix: + bar.Prefix(msg.Arg.(string)) case cpBarCmdExtend: atomic.AddInt64(&bar.Total, msg.Arg.(int64)) if bar.Total > 0 && !started {