File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ import (
14
14
15
15
// Long - Format listing in long format.
16
16
func Long (nodes []node.Node ) {
17
+ displaySummary (nodes )
18
+
17
19
// populate values
18
20
values := make ([][]string , len (nodes ))
19
21
for i := range values {
@@ -49,6 +51,31 @@ func Long(nodes []node.Node) {
49
51
}
50
52
}
51
53
54
+ func displaySummary (nodes []node.Node ) {
55
+ dirCount := 0
56
+ dirSize := 0
57
+ fileCount := 0
58
+ fileSize := 0
59
+ for _ , node := range nodes {
60
+ if node .IsDir {
61
+ dirCount ++
62
+ dirSize += node .Size
63
+ } else {
64
+ fileCount ++
65
+ fileSize += node .Size
66
+ }
67
+ }
68
+ fmt .Printf (
69
+ "%s (%s @ %s) & %s (%s @ %s)\n " ,
70
+ color .New (color .FgWhite , color .Bold ).Sprint ("files" ),
71
+ color .New (color .FgMagenta , color .Bold ).Sprint (fileCount ),
72
+ formatSize (fileSize ),
73
+ color .New (color .FgWhite , color .Bold ).Sprint ("directories" ),
74
+ color .New (color .FgMagenta , color .Bold ).Sprint (dirCount ),
75
+ formatSize (dirSize ),
76
+ )
77
+ }
78
+
52
79
func extractValues (node node.Node ) []string {
53
80
return []string {
54
81
formatMode (node .Mode ),
You can’t perform that action at this time.
0 commit comments