Skip to content

Commit

Permalink
Initial node coloring.
Browse files Browse the repository at this point in the history
  • Loading branch information
drn committed Sep 1, 2018
1 parent 6bbb00a commit 77985fe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion node/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"fmt"
"io/ioutil"
"github.com/fatih/color"
)

// Node - File or directory helper methods
Expand Down Expand Up @@ -35,7 +36,7 @@ func Fetch() []Node {

func (n node) Name() string {
if n.name != "" { return n.name }
n.name = fmt.Sprintf("%c %s/ ", n.icon(), n.file.Name())
n.name = fmt.Sprintf("%c %s/ ", n.icon(), n.color()(n.file.Name()))
return n.name
}

Expand All @@ -44,6 +45,10 @@ func (n node) icon() rune {
return ' '
}

func (n node) color() func(a ...interface{}) string {
return color.New(color.FgCyan, color.Bold).SprintFunc()
}

func (n node) Size() int {
if n.size != 0 { return n.size }
n.size = len([]rune(n.Name()))
Expand Down

0 comments on commit 77985fe

Please sign in to comment.