package main import ( "strconv" "time" "github.com/docopt/docopt-go" ) const usage = `Link checker for Markdown and HTML Usage: linkcheck [-t ] [-v] ... Options: -v, --verbose Be verbose -t, --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[""].([]string), time.Duration(f) * time.Second, args["--verbose"].(bool), }, nil }