mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-06 03:31:02 -06:00
[server][cli] Print version history in ls
This commit is contained in:
@@ -54,7 +54,8 @@ func FormatSize(size int) string {
|
||||
for ; sz >= 1000 && si < len(suffix); si, sz = si+1, sz/1024 {
|
||||
}
|
||||
if sz >= 10 || si == 0 {
|
||||
return fmt.Sprintf("%4d%s", int(math.Ceil(sz)), suffix[si])
|
||||
return strconv.Itoa(int(math.Ceil(sz))) + suffix[si]
|
||||
// return fmt.Sprintf("%d%s", int(math.Ceil(sz)), suffix[si])
|
||||
} else {
|
||||
return fmt.Sprintf("%1.1f%s", sz, suffix[si])
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func setupCatCommand() *cobra.Command {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
v, err := f.FindVersion(r, uuid.Nil)
|
||||
v, err := f.GetVersion(r, uuid.Nil)
|
||||
if err != nil {
|
||||
fmt.Println("cannot find latest version of '" + path + "': " + err.Error())
|
||||
os.Exit(1)
|
||||
|
||||
@@ -85,8 +85,24 @@ to the resource with a particular ID.`,
|
||||
fmt.Println(common.FormatResourceSummary(c, "", r.Deleted()))
|
||||
}
|
||||
} else {
|
||||
fmt.Println(" Size: " + common.FormatSize(int(r.LatestVersion().Size)))
|
||||
fmt.Println("SHA-256: " + r.LatestVersion().SHA256[0:12])
|
||||
fmt.Println(" Size: " + common.FormatSize(int(r.LatestVersion().Size)))
|
||||
fmt.Println(" SHA-256: " + r.LatestVersion().SHA256[0:12])
|
||||
versions, err := f.GetAllVersions(r)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("Versions: " + strconv.Itoa(len(versions)))
|
||||
for i, v := range versions {
|
||||
extra := ""
|
||||
if i == 0 {
|
||||
extra += " [current]"
|
||||
}
|
||||
if v.Deleted != 0 {
|
||||
extra += " [deleted]"
|
||||
}
|
||||
fmt.Printf("%s %5s %s %s%s\n", v.ID.String(), common.FormatSize(int(v.Size)), v.SHA256[0:12], time.Unix(int64(v.Created), 0).Local().Format(time.RFC1123), extra)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user