Skip to content

Commit 54afc33

Browse files
committed
use util.OptionalString
1 parent fdf172c commit 54afc33

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

internal/cmd/storagebox/list.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,15 @@ var ListCmd = base.ListCmd[*hcloud.StorageBox, schema.StorageBox]{
3232
}).
3333
AddFieldFn("username", func(obj any) string {
3434
storageBox := obj.(*hcloud.StorageBox)
35-
if storageBox.Username == nil {
36-
return "-"
37-
}
38-
return *storageBox.Username
35+
return util.OptionalString(storageBox.Username, "-")
3936
}).
4037
AddFieldFn("server", func(obj any) string {
4138
storageBox := obj.(*hcloud.StorageBox)
42-
if storageBox.Server == nil {
43-
return "-"
44-
}
45-
return *storageBox.Server
39+
return util.OptionalString(storageBox.Server, "-")
4640
}).
4741
AddFieldFn("system", func(obj any) string {
4842
storageBox := obj.(*hcloud.StorageBox)
49-
if storageBox.System == nil {
50-
return "-"
51-
}
52-
return *storageBox.System
43+
return util.OptionalString(storageBox.System, "-")
5344
}).
5445
AddFieldFn("location", func(obj any) string {
5546
storageBox := obj.(*hcloud.StorageBox)

0 commit comments

Comments
 (0)