Browse Source

Add verbose option

renovate/configure
Yota Toyama 8 years ago
parent
commit
ae7fb6452b
  1. 16
      examples/markdown.feature
  2. 7
      main.go

16
examples/markdown.feature

@ -41,3 +41,19 @@ Feature: Markdown
When I run `linkcheck foo.md`
Then the exit status should be 1
And the stderr should contain "ERROR"
Scenario: Check a markdown file which contains a live link in verbose mode
Given a file named "foo.md" with:
"""
[Google](https://google.com)
"""
When I successfully run `linkcheck -v foo.md`
Then the stderr should contain "OK"
Scenario: Check a markdown file which contains a live link in verbose mode with a long option
Given a file named "foo.md" with:
"""
[Google](https://google.com)
"""
When I successfully run `linkcheck --verbose foo.md`
Then the stderr should contain "OK"

7
main.go

@ -44,6 +44,8 @@ func main() {
if _, err := http.Get(s); err != nil {
printToStderr(color.New(color.FgRed).SprintFunc()("ERROR") + "\t" + colored + "\t" + err.Error())
ok = false
} else if err == nil && args["--verbose"].(bool) {
printToStderr(color.New(color.FgGreen).SprintFunc()("OK") + "\t" + colored)
}
}
@ -88,7 +90,10 @@ func getArgs() map[string]interface{} {
usage := `Link checker for Markdown and HTML
Usage:
linkcheck <filename>`
linkcheck [-v] <filename>
Options:
-v, --verbose Be verbose`
args, err := docopt.Parse(usage, nil, true, "linkcheck", true)

Loading…
Cancel
Save