Treating --json as quiet mode for cp and sync operations
This commit is contained in:
@@ -93,11 +93,12 @@ func doCopySession(cURLs cpURLs, bar *barSend, s *sessionV1) error {
|
||||
defer reader.Close()
|
||||
|
||||
var newReader io.Reader
|
||||
switch globalQuietFlag {
|
||||
switch globalQuietFlag || globalJSONFlag {
|
||||
case true:
|
||||
console.Infos(CopyMessage{
|
||||
Source: cURLs.SourceContent.Name,
|
||||
Target: cURLs.TargetContent.Name,
|
||||
Length: cURLs.SourceContent.Size,
|
||||
})
|
||||
newReader = yielder.NewReader(reader)
|
||||
default:
|
||||
|
||||
+3
-4
@@ -23,7 +23,6 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/minio/cli"
|
||||
@@ -108,11 +107,11 @@ func doSyncSession(sURLs syncURLs, bar *barSend, syncQueue chan bool, ssCh chan
|
||||
}
|
||||
|
||||
var newReader io.Reader
|
||||
switch globalQuietFlag {
|
||||
switch globalQuietFlag || globalJSONFlag {
|
||||
case true:
|
||||
console.Infos(SyncMessage{
|
||||
Source: sURLs.SourceContent.Name,
|
||||
Target: strings.Join(targetURLs, " "),
|
||||
Source: sURLs.SourceContent.Name,
|
||||
Targets: targetURLs,
|
||||
})
|
||||
newReader = yielder.NewReader(reader)
|
||||
default:
|
||||
|
||||
+13
-9
@@ -26,7 +26,7 @@ import (
|
||||
|
||||
// ErrorMessage container for error reason encapsulation
|
||||
type ErrorMessage struct {
|
||||
Message string `json:"message"`
|
||||
Message string `json:"-"`
|
||||
Error error `json:"error"`
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ func (e ErrorMessage) String() string {
|
||||
switch e.Error.(type) {
|
||||
case iodine.Error:
|
||||
reason := iodine.ToError(e.Error).Error()
|
||||
message = e.Message + ", " + reason
|
||||
message = reason
|
||||
default:
|
||||
reason := e.Error.Error()
|
||||
message = e.Message + ", " + reason
|
||||
message = reason
|
||||
}
|
||||
}
|
||||
return message
|
||||
@@ -69,7 +69,7 @@ func (c Content) String() string {
|
||||
|
||||
// InfoMessage container for informational messages
|
||||
type InfoMessage struct {
|
||||
Message string `json:"message"`
|
||||
Message string `json:"info"`
|
||||
}
|
||||
|
||||
// String string printer for informational message
|
||||
@@ -79,9 +79,9 @@ func (i InfoMessage) String() string {
|
||||
|
||||
// CopyMessage container for file copy messages
|
||||
type CopyMessage struct {
|
||||
Message string `json:"message"`
|
||||
Source string `json:"source"`
|
||||
Target string `json:"target"`
|
||||
Source string `json:"source"`
|
||||
Target string `json:"target"`
|
||||
Length int64 `json:"length"`
|
||||
}
|
||||
|
||||
// String string printer for copy message
|
||||
@@ -90,9 +90,13 @@ func (c CopyMessage) String() string {
|
||||
}
|
||||
|
||||
// SyncMessage container for file sync messages, inherits CopyMessage
|
||||
type SyncMessage CopyMessage
|
||||
type SyncMessage struct {
|
||||
Source string `json:"source"`
|
||||
Targets []string `json:"targets"`
|
||||
Length int64 `json:"length"`
|
||||
}
|
||||
|
||||
// String string printer for sync message
|
||||
func (s SyncMessage) String() string {
|
||||
return fmt.Sprintf("‘%s’ -> ‘%s’", s.Source, s.Target)
|
||||
return fmt.Sprintf("‘%s’ -> ‘%s’", s.Source, s.Targets)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user