Skip to content

Commit 5896f70

Browse files
committed
Move extractValues out of format.Long().
1 parent 567b043 commit 5896f70

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

format/long.go

+15-12
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,7 @@ func Long(nodes []node.Node) {
2121
// populate values
2222
values := make([][]string, len(nodes))
2323
for i := range values {
24-
node := nodes[i]
25-
values[i] = []string{
26-
formatMode(node.Mode),
27-
strconv.Itoa(node.LinkCount),
28-
fmt.Sprintf("%s ", node.User),
29-
fmt.Sprintf("%s ", node.Group),
30-
colorSize(node.Size, humanize.Bytes(node.Size)),
31-
node.Time.Month().String()[:3],
32-
fmt.Sprintf("%2d", node.Time.Day()),
33-
fmt.Sprintf("%02d:%02d", node.Time.Hour(), node.Time.Minute()),
34-
fmt.Sprintf(" %s", node.Name),
35-
}
24+
values[i] = extractValues(nodes[i])
3625
}
3726

3827
// calculate lengths and max lengths
@@ -64,6 +53,20 @@ func Long(nodes []node.Node) {
6453
}
6554
}
6655

56+
func extractValues(node node.Node) []string {
57+
return []string{
58+
formatMode(node.Mode),
59+
strconv.Itoa(node.LinkCount),
60+
fmt.Sprintf("%s ", node.User),
61+
fmt.Sprintf("%s ", node.Group),
62+
colorSize(node.Size, humanize.Bytes(node.Size)),
63+
node.Time.Month().String()[:3],
64+
fmt.Sprintf("%2d", node.Time.Day()),
65+
fmt.Sprintf("%02d:%02d", node.Time.Hour(), node.Time.Minute()),
66+
fmt.Sprintf(" %s", node.Name),
67+
}
68+
}
69+
6770
func colorSize(sizeInt int, str string) string {
6871
size := float64(sizeInt)
6972
base := float64(1024)

0 commit comments

Comments
 (0)