Skip to content

Commit

Permalink
cli/container: Pretty-print creation timestamp in list-objects output
Browse files Browse the repository at this point in the history
Previously, `container list-object` command with `--with-attr` flag
printed objects' attributes in raw way. In particular, creation
timestamp was showed in Unix format (e.g. 1692609422). While this format
is widely known, its human-unreadable. To facilitate the user's
experience, the output should be supplemented with a readable format
similar to the `object head` command.

Use Go `time.Time` stringer and print the result along with Unix time
value. From:
```
HKupeALCqk3VUSmuRXTGdJt6ZZQoJsJ3VtNVV8Pu1Xjd
  Timestamp=1692609422
```
to:
```
HKupeALCqk3VUSmuRXTGdJt6ZZQoJsJ3VtNVV8Pu1Xjd
  Timestamp=1692609422 (2023-08-21 11:17:02 +0200 CEST)
```

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Nov 20, 2023
1 parent 8d9a2bc commit 471d7f5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/neofs-cli/modules/container/list_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ var listContainerObjectsCmd = &cobra.Command{
if err == nil {
attrs := resHead.Header().UserAttributes()
for i := range attrs {
cmd.Printf(" %s: %s\n", attrs[i].Key(), attrs[i].Value())
key := attrs[i].Key()
val := attrs[i].Value()

if key := attrs[i].Key(); key == object.AttributeTimestamp {
cmd.Printf(" %s=%s (%s)\n", key, val, common.PrettyPrintUnixTime(val))
continue
}

cmd.Printf(" %s: %s\n", key, val)
}
} else {
cmd.Printf(" failed to read attributes: %v\n", err)
Expand Down

0 comments on commit 471d7f5

Please sign in to comment.