Skip to content

Commit 609f0e5

Browse files
committed
Prototype -a flag support.
1 parent c345038 commit 609f0e5

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

main.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ func main() {
2525
os.Exit(1)
2626
}
2727

28-
nodes := node.Fetch()
28+
nodes := node.Fetch(
29+
map[string]bool{
30+
"all": *all,
31+
},
32+
)
2933

3034
count := 0
3135
maxSize := maxSize(nodes)

node/root.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,23 @@ type Node struct {
3232
}
3333

3434
// Fetch - Fetch nodes in currently directory
35-
func Fetch() []Node {
35+
func Fetch(options map[string]bool) []Node {
3636
files, err := ioutil.ReadDir(".")
3737
if err != nil { log.Fatal(err) }
3838

39-
nodes := make([]Node, len(files))
39+
count := 0
40+
for i:=0; i<len(files); i++ {
41+
if !options["all"] && []rune(files[i].Name())[0] == '.' { continue }
42+
count++
43+
}
44+
45+
nodes := make([]Node, count)
4046

47+
count = 0
4148
for i:=0; i<len(files); i++ {
42-
nodes[i] = new(files[i])
49+
if !options["all"] && []rune(files[i].Name())[0] == '.' { continue }
50+
nodes[count] = new(files[i])
51+
count++
4352
}
4453

4554
return nodes

0 commit comments

Comments
 (0)