Skip to content

Commit d9de247

Browse files
author
Rıza Sabuncu
committed
feat: onlyfiles, hide tree
1 parent 6c6d8a2 commit d9de247

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

main.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ const (
2929

3030
treeBranch = `├── `
3131
treeEnd = `└── `
32+
treeSuffix = `│ `
3233
)
3334

3435
type (
3536
Options struct {
36-
URL string
37-
Banner bool
37+
URL string
38+
Banner bool
39+
Tree bool
40+
ShowOnlyFiles bool
3841

3942
Extensions []string
4043
Matchers []string
@@ -54,6 +57,17 @@ func main() {
5457

5558
go func() {
5659
for l := range line {
60+
if !options.Tree {
61+
l = strings.ReplaceAll(l, treeBranch, "")
62+
l = strings.ReplaceAll(l, treeEnd, "")
63+
l = strings.ReplaceAll(l, treeSuffix, "")
64+
l = strings.ReplaceAll(l, " ", "")
65+
}
66+
67+
if options.ShowOnlyFiles && strings.HasSuffix(l, "/") {
68+
continue
69+
}
70+
5771
fmt.Println(l)
5872
}
5973
}()
@@ -90,6 +104,8 @@ func parseOptions() *Options {
90104
flag.StringVar(&extensions, "e", "", "extensions to filter, example: -e jpg,png,gif")
91105
flag.StringVar(&matchers, "m", "", "match in url, example: -mu admin,login")
92106
flag.BoolVar(&options.Banner, "b", true, "show banner")
107+
flag.BoolVar(&options.Tree, "t", true, "show tree")
108+
flag.BoolVar(&options.ShowOnlyFiles, "of", false, "show only files")
93109

94110
flag.Parse()
95111

@@ -132,7 +148,7 @@ func crawl(line chan string, wg *sync.WaitGroup, url string, extensions, matcher
132148
for i, u := range urls {
133149
u = url + u
134150

135-
suffix := "│ "
151+
suffix := treeSuffix
136152
if i == len(urls)-1 {
137153
suffix = " "
138154
}

0 commit comments

Comments
 (0)