ls: New output format when versioning is enabled (#3392)
This commit is contained in:
+4
-1
@@ -169,7 +169,10 @@ func mainList(cliCtx *cli.Context) error {
|
||||
|
||||
// Additional command specific theme customization.
|
||||
console.SetColor("File", color.New(color.Bold))
|
||||
console.SetColor("DeletedFile", color.New(color.Bold, color.FgRed))
|
||||
console.SetColor("DEL", color.New(color.FgRed))
|
||||
console.SetColor("PUT", color.New(color.FgGreen))
|
||||
console.SetColor("VersionID", color.New(color.FgHiBlue))
|
||||
console.SetColor("VersionOrd", color.New(color.FgHiMagenta))
|
||||
console.SetColor("Dir", color.New(color.FgCyan, color.Bold))
|
||||
console.SetColor("Size", color.New(color.FgYellow))
|
||||
console.SetColor("Time", color.New(color.FgGreen))
|
||||
|
||||
@@ -47,24 +47,28 @@ type contentMessage struct {
|
||||
URL string `json:"url,omitempty"`
|
||||
|
||||
VersionID string `json:"versionId,omitempty"`
|
||||
VersionOrd string `json:"versionOrdinal,omitempty"`
|
||||
VersionOrd int `json:"versionOrdinal,omitempty"`
|
||||
VersionIndex int `json:"versionIndex,omitempty"`
|
||||
IsDeleteMarker bool `json:"isDeleteMarker,omitempty"`
|
||||
}
|
||||
|
||||
// String colorized string message.
|
||||
func (c contentMessage) String() string {
|
||||
message := console.Colorize("Time", fmt.Sprintf("[%s] ", c.Time.Format(printDate)))
|
||||
message += console.Colorize("Size", fmt.Sprintf("%7s ", strings.Join(strings.Fields(humanize.IBytes(uint64(c.Size))), "")))
|
||||
fileDesc := c.Key
|
||||
message := console.Colorize("Time", fmt.Sprintf("[%s]", c.Time.Format(printDate)))
|
||||
message += console.Colorize("Size", fmt.Sprintf("%7s", strings.Join(strings.Fields(humanize.IBytes(uint64(c.Size))), "")))
|
||||
fileDesc := ""
|
||||
|
||||
if c.VersionID != "" {
|
||||
fileDesc += fmt.Sprintf(" (%s, vid=%s", c.VersionOrd, c.VersionID)
|
||||
fileDesc += console.Colorize("VersionID", " "+c.VersionID) + console.Colorize("VersionOrd", fmt.Sprintf(" v%d", c.VersionOrd))
|
||||
if c.IsDeleteMarker {
|
||||
fileDesc += ", delete-marker"
|
||||
fileDesc += console.Colorize("DEL", " DEL")
|
||||
} else {
|
||||
fileDesc += console.Colorize("PUT", " PUT")
|
||||
}
|
||||
fileDesc += ")"
|
||||
}
|
||||
|
||||
fileDesc += " " + c.Key
|
||||
|
||||
if c.Filetype == "folder" {
|
||||
message += console.Colorize("Dir", fileDesc)
|
||||
} else {
|
||||
@@ -140,7 +144,7 @@ func generateContentMessages(clntURL ClientURL, ctnts []*ClientContent, printAll
|
||||
contentMsg.Key = getKey(c)
|
||||
contentMsg.VersionID = c.VersionID
|
||||
contentMsg.IsDeleteMarker = c.IsDeleteMarker
|
||||
contentMsg.VersionOrd = humanize.Ordinal(nrVersions - i)
|
||||
contentMsg.VersionOrd = nrVersions - i
|
||||
// URL is empty by default
|
||||
// Set it to either relative dir (host) or public url (remote)
|
||||
contentMsg.URL = clntURL.String()
|
||||
|
||||
Reference in New Issue
Block a user