Browse Source

Fix verbose option

renovate/configure
Yota Toyama 8 years ago
parent
commit
13a21486cf
  1. 10
      file_checker.go
  2. 4
      main.go
  3. 7
      url_checker.go

10
file_checker.go

@ -14,8 +14,8 @@ type fileChecker struct {
urlChecker urlChecker
}
func newFileChecker(timeout time.Duration, verbose bool) fileChecker {
return fileChecker{newURLChecker(timeout, verbose)}
func newFileChecker(timeout time.Duration) fileChecker {
return fileChecker{newURLChecker(timeout)}
}
func (c fileChecker) Check(f string) ([]urlResult, error) {
@ -50,11 +50,13 @@ type fileResult struct {
err error
}
func (r fileResult) String() string {
func (r fileResult) String(verbose bool) string {
ss := make([]string, 0, len(r.urlResults))
for _, r := range r.urlResults {
ss = append(ss, "\t"+r.String())
if r.err != nil || verbose {
ss = append(ss, "\t"+r.String())
}
}
return strings.Join(append([]string{r.filename}, ss...), "\n")

4
main.go

@ -28,7 +28,7 @@ func main() {
args := getArgs()
fs := args["<filenames>"].([]string)
rc := make(chan fileResult, len(fs))
c := newFileChecker(5*time.Second, args["--verbose"].(bool))
c := newFileChecker(5 * time.Second)
for _, f := range fs {
go func(f string) {
@ -49,7 +49,7 @@ func main() {
ok = ok && r.Ok()
printToStderr(r.String())
printToStderr(r.String(args["--verbose"].(bool)))
}
if !ok {

7
url_checker.go

@ -9,12 +9,11 @@ import (
)
type urlChecker struct {
client http.Client
verbose bool
client http.Client
}
func newURLChecker(timeout time.Duration, verbose bool) urlChecker {
return urlChecker{http.Client{Timeout: timeout}, verbose}
func newURLChecker(timeout time.Duration) urlChecker {
return urlChecker{http.Client{Timeout: timeout}}
}
func (c urlChecker) Check(s string) error {

Loading…
Cancel
Save