MCPcopy
hub / github.com/raviqqe/muffet / runWithError

Method runWithError

command.go:35–146  ·  view source on GitHub ↗
(ss []string)

Source from the content-addressed store, hash-verified

33}
34
35func (c *command) runWithError(ss []string) (bool, error) {
36 args, err := getArguments(ss)
37 if err != nil {
38 return false, err
39 } else if args.Help {
40 c.print(help())
41 return true, nil
42 } else if args.Version {
43 c.print(version)
44 return true, nil
45 }
46
47 client := newCheckedHttpClient(
48 newRedirectHttpClient(
49 newRetryHttpClient(
50 newThrottledHttpClient(
51 c.httpClientFactory.Create(
52 httpClientOptions{
53 MaxConnectionsPerHost: args.MaxConnectionsPerHost,
54 MaxResponseBodySize: args.MaxResponseBodySize,
55 BufferSize: args.BufferSize,
56 Proxy: args.Proxy,
57 SkipTLSVerification: args.SkipTLSVerification,
58 Timeout: time.Duration(args.Timeout) * time.Second,
59 Header: args.Header,
60 DnsResolver: args.DnsResolver,
61 },
62 ),
63 args.RateLimit,
64 args.MaxConnections,
65 args.MaxConnectionsPerHost,
66 ),
67 args.MaxRetries,
68 initialRetryDelay,
69 ),
70 args.MaxRedirections,
71 ),
72 args.AcceptedStatusCodes,
73 )
74
75 fl := newLinkFilterer(args.ExcludedPatterns, args.IncludePatterns)
76
77 f := newLinkFetcher(
78 client,
79 []pageParser{
80 newSitemapPageParser(fl),
81 newHtmlPageParser(newLinkFinder(fl)),
82 },
83 linkFetcherOptions{
84 IgnoreFragments: args.IgnoreFragments,
85 },
86 )
87
88 _, p, err := f.Fetch(args.URL)
89 if err != nil {
90 return false, fmt.Errorf("failed to fetch root page: %v", err)
91 } else if p == nil {
92 return false, errors.New("root page has invalid content type")

Callers 1

RunMethod · 0.95

Calls 15

printMethod · 0.95
printResultsInJSONMethod · 0.95
getArgumentsFunction · 0.85
helpFunction · 0.85
newCheckedHttpClientFunction · 0.85
newRedirectHttpClientFunction · 0.85
newRetryHttpClientFunction · 0.85
newThrottledHttpClientFunction · 0.85
newLinkFiltererFunction · 0.85
newLinkFetcherFunction · 0.85
newSitemapPageParserFunction · 0.85

Tested by

no test coverage detected