Skip to content

Commit 41e524d

Browse files
committed
Adjust format options to map[string]int.
1 parent cc82460 commit 41e524d

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

format/compact.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
// Compact - Format listing in compact format.
11-
func Compact(nodes []node.Node, options map[string]bool) {
11+
func Compact(nodes []node.Node, options map[string]int) {
1212
width := util.TerminalWidth()
1313

1414
if width == 0 {
@@ -24,7 +24,7 @@ func pipedDisplay(nodes []node.Node) {
2424
}
2525
}
2626

27-
func compactDisplay(nodes []node.Node, width int, options map[string]bool) {
27+
func compactDisplay(nodes []node.Node, width int, options map[string]int) {
2828
// determine max node length
2929
maxLength := 0
3030
for _, node := range nodes {
@@ -33,15 +33,15 @@ func compactDisplay(nodes []node.Node, width int, options map[string]bool) {
3333
}
3434

3535
lengthPerNode := maxLength + 2 // name + 2 spaces
36-
if options["icon"] { lengthPerNode += 3 } // icon + 2 spaces
36+
if options["icon"] == 1 { lengthPerNode += 3 } // icon + 2 spaces
3737
nodesPerRow := width / lengthPerNode
3838
nodesLength := len(nodes)
3939

4040
for i := 0; i < nodesLength; i ++ {
4141
node := nodes[i]
4242

4343
// print node
44-
if !options["icon"] {
44+
if options["icon"] == 0 {
4545
fmt.Print(nodeColor(node).Sprint(node.Name))
4646
} else {
4747
fmt.Printf(

format/long.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
// Long - Format listing in long format.
16-
func Long(nodes []node.Node, options map[string]bool) {
16+
func Long(nodes []node.Node, options map[string]int) {
1717
displaySummary(nodes)
1818

1919
// populate values
@@ -76,8 +76,8 @@ func displaySummary(nodes []node.Node) {
7676
)
7777
}
7878

79-
func extractValues(node node.Node, options map[string]bool) []string {
80-
if options["icon"] {
79+
func extractValues(node node.Node, options map[string]int) []string {
80+
if options["icon"] == 1 {
8181
return []string{
8282
formatMode(node.Mode),
8383
strconv.Itoa(node.LinkCount),

format/root.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ func Display(address string, opts options.Options) {
2121
},
2222
)
2323

24-
formatOptions := map[string]bool{"icon": opts.Icon}
2524
if opts.Long {
26-
Long(nodes, formatOptions)
25+
Long(nodes, formatOptions(opts))
2726
} else {
28-
Compact(nodes, formatOptions)
27+
Compact(nodes, formatOptions(opts))
28+
}
29+
}
30+
31+
func formatOptions(opts options.Options) map[string]int {
32+
icon := 0; if opts.Icon { icon = 1 }
33+
return map[string]int{
34+
"icon": icon,
2935
}
3036
}
3137

0 commit comments

Comments
 (0)