Skip to content

Commit

Permalink
CLI: list-objects: color virtual dirs
Browse files Browse the repository at this point in the history
* and show nothing in the "cached" column

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Jun 27, 2024
1 parent b630043 commit 592f63b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion cmd/cli/teb/lso.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down Expand Up @@ -109,5 +109,8 @@ func fmtLsObjStatus(e *cmn.LsoEnt) string {
}

func fmtLsObjIsCached(e *cmn.LsoEnt) string {
if e.IsDir() {
return ""
}
return FmtBool(e.IsPresent())
}
2 changes: 1 addition & 1 deletion cmd/cli/teb/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions cmd/cli/teb/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 592f63b

Please sign in to comment.