From 592f63bfd8149b735b9b01cdc79fd5b081697489 Mon Sep 17 00:00:00 2001 From: Alex Aizman Date: Thu, 27 Jun 2024 15:21:43 -0400 Subject: [PATCH] CLI: list-objects: color virtual dirs * and show nothing in the "cached" column Signed-off-by: Alex Aizman --- cmd/cli/teb/lso.go | 5 ++++- cmd/cli/teb/templates.go | 2 +- cmd/cli/teb/utils.go | 9 ++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/cli/teb/lso.go b/cmd/cli/teb/lso.go index 3386babf2e..9c36e36e45 100644 --- a/cmd/cli/teb/lso.go +++ b/cmd/cli/teb/lso.go @@ -15,7 +15,7 @@ import ( var ( // ObjectPropsMap matches ObjEntry field ObjectPropsMap = map[string]string{ - apc.GetPropsName: "{{FormatNameArch $obj.Name $obj.Flags}}", + apc.GetPropsName: "{{FormatNameDirArch $obj.Name $obj.Flags}}", apc.GetPropsSize: "{{FormatBytesSig2 $obj.Size 2 $obj.Flags}}", apc.GetPropsChecksum: "{{$obj.Checksum}}", apc.GetPropsAtime: "{{$obj.Atime}}", @@ -109,5 +109,8 @@ func fmtLsObjStatus(e *cmn.LsoEnt) string { } func fmtLsObjIsCached(e *cmn.LsoEnt) string { + if e.IsDir() { + return "" + } return FmtBool(e.IsPresent()) } diff --git a/cmd/cli/teb/templates.go b/cmd/cli/teb/templates.go index b66028fc4b..bfeec21ee9 100644 --- a/cmd/cli/teb/templates.go +++ b/cmd/cli/teb/templates.go @@ -425,7 +425,7 @@ var ( "FormatBool": FmtBool, "FormatBckName": func(bck cmn.Bck) string { return bck.Cname("") }, "FormatACL": fmtACL, - "FormatNameArch": fmtNameArch, + "FormatNameDirArch": fmtNameDirArch, "FormatXactState": FmtXactStatus, // misc. helpers "IsUnsetTime": isUnsetTime, diff --git a/cmd/cli/teb/utils.go b/cmd/cli/teb/utils.go index 29b28e42e5..fb2a6b455a 100644 --- a/cmd/cli/teb/utils.go +++ b/cmd/cli/teb/utils.go @@ -206,10 +206,13 @@ func fmtACL(acl apc.AccessAttrs) string { return acl.Describe(true /*incl. all*/) } -func fmtNameArch(val string, flags uint16) string { +func fmtNameDirArch(val string, flags uint16) string { if flags&apc.EntryInArch == 0 { - if flags&apc.EntryIsDir != 0 && !cos.IsLastB(val, '/') { - return val + "/" + if flags&apc.EntryIsDir != 0 { + if !cos.IsLastB(val, '/') { + val += "/" + } + return fgreen(val) } return val }