forked from raviqqe/liche
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_result.go
54 lines (41 loc) · 895 Bytes
/
file_result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"sort"
"strings"
"github.com/fatih/color"
)
type fileResult struct {
filename string
urlResults []urlResult
err error
}
func (r fileResult) String(verbose bool) string {
ss := make([]string, 0, len(r.urlResults))
if r.err != nil {
ss = append(ss, indent(color.RedString(capitalizeFirst(r.err.Error()))))
}
os := make([]string, 0, len(r.urlResults))
xs := make([]string, 0, len(r.urlResults))
for _, r := range r.urlResults {
s := indent(r.String())
if r.err != nil {
xs = append(xs, s)
} else if verbose {
os = append(os, s)
}
}
sort.Strings(os)
sort.Strings(xs)
return strings.Join(append([]string{r.filename}, append(ss, append(os, xs...)...)...), "\n")
}
func (r fileResult) Ok() bool {
if r.err != nil {
return false
}
for _, r := range r.urlResults {
if r.err != nil {
return false
}
}
return true
}