Fast Link Checker for Markdown and HTML in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

43 lines
771 B

package main
import (
"strconv"
"time"
"github.com/docopt/docopt-go"
)
const usage = `Link checker for Markdown and HTML
Usage:
linkcheck [-t <timeout>] [-v] <filenames>...
Options:
-v, --verbose Be verbose
-t, --timeout <timeout> Set timeout for HTTP requests in seconds [default: 5]`
type arguments struct {
filenames []string
timeout time.Duration
verbose bool
}
func getArgs() (arguments, error) {
args, err := docopt.Parse(usage, nil, true, "linkcheck", true)
if err != nil {
return arguments{}, err
}
f, err := strconv.ParseFloat(args["--timeout"].(string), 64)
if err != nil {
return arguments{}, err
}
return arguments{
args["<filenames>"].([]string),
time.Duration(f) * time.Second,
args["--verbose"].(bool),
}, nil
}