diff --git a/.snapshots/TestHelp b/.snapshots/TestHelp index c265d59..6edfebe 100644 --- a/.snapshots/TestHelp +++ b/.snapshots/TestHelp @@ -18,16 +18,9 @@ Application Options: regular expressions --follow-robots-txt Follow robots.txt when scraping pages - --follow-sitemap-xml Scrape only pages listed in - sitemap.xml (deprecated) --header=
... Custom headers -f, --ignore-fragments Ignore URL fragments --format=[text|json|junit] Output format (default: text) - --json Output results in JSON (deprecated) - --experimental-verbose-json Include successful results in JSON - (deprecated) - --junit Output results as JUnit XML file - (deprecated) -r, --max-redirections= Maximum number of redirections (default: 64) --rate-limit= Max requests per second diff --git a/arguments.go b/arguments.go index dd962c0..95abc13 100644 --- a/arguments.go +++ b/arguments.go @@ -19,17 +19,10 @@ type arguments struct { RawExcludedPatterns []string `short:"e" long:"exclude" value-name:"..." description:"Exclude URLs matched with given regular expressions"` RawIncludedPatterns []string `short:"i" long:"include" value-name:"..." description:"Include URLs matched with given regular expressions"` FollowRobotsTxt bool `long:"follow-robots-txt" description:"Follow robots.txt when scraping pages"` - FollowSitemapXML bool `long:"follow-sitemap-xml" description:"Scrape only pages listed in sitemap.xml (deprecated)"` RawHeaders []string `long:"header" value-name:"
..." description:"Custom headers"` // TODO Remove a short option. - IgnoreFragments bool `short:"f" long:"ignore-fragments" description:"Ignore URL fragments"` - Format string `long:"format" description:"Output format" default:"text" choice:"text" choice:"json" choice:"junit"` - // TODO Remove this option. - JSONOutput bool `long:"json" description:"Output results in JSON (deprecated)"` - // TODO Remove this option. - VerboseJSON bool `long:"experimental-verbose-json" description:"Include successful results in JSON (deprecated)"` - // TODO Remove this option. - JUnitOutput bool `long:"junit" description:"Output results as JUnit XML file (deprecated)"` + IgnoreFragments bool `short:"f" long:"ignore-fragments" description:"Ignore URL fragments"` + Format string `long:"format" description:"Output format" default:"text" choice:"text" choice:"json" choice:"junit"` MaxRedirections int `short:"r" long:"max-redirections" value-name:"" default:"64" description:"Maximum number of redirections"` RateLimit int `long:"rate-limit" value-name:"" description:"Max requests per second"` Timeout int `short:"t" long:"timeout" value-name:"" default:"10" description:"Timeout for HTTP requests in seconds"` @@ -59,8 +52,6 @@ func getArguments(ss []string) (*arguments, error) { return nil, errors.New("invalid number of arguments") } - reconcileDeprecatedArguments(&args) - args.URL = ss[0] args.ExcludedPatterns, err = compileRegexps(args.RawExcludedPatterns) @@ -133,12 +124,3 @@ func parseHeaders(headers []string) (http.Header, error) { return h, nil } - -func reconcileDeprecatedArguments(args *arguments) { - if args.JSONOutput { - args.Format = "json" - args.Verbose = args.Verbose || args.VerboseJSON - } else if args.JUnitOutput { - args.Format = "junit" - } -} diff --git a/arguments_test.go b/arguments_test.go index 983ad69..49d6af3 100644 --- a/arguments_test.go +++ b/arguments_test.go @@ -25,7 +25,6 @@ func TestGetArguments(t *testing.T) { {"-r", "4", "https://foo.com"}, {"--max-redirections", "4", "https://foo.com"}, {"--follow-robots-txt", "https://foo.com"}, - {"--follow-sitemap-xml", "https://foo.com"}, {"-t", "10", "https://foo.com"}, {"--timeout", "10", "https://foo.com"}, {"--rate-limit", "1", "https://foo.com"}, @@ -36,7 +35,7 @@ func TestGetArguments(t *testing.T) { {"-v", "-f", "https://foo.com"}, {"-v", "--ignore-fragments", "https://foo.com"}, {"--one-page-only", "https://foo.com"}, - {"--json", "https://foo.com"}, + {"--format=json", "https://foo.com"}, {"-h"}, {"--help"}, {"--version"}, diff --git a/command.go b/command.go index bb5f8e6..dc012d6 100644 --- a/command.go +++ b/command.go @@ -99,14 +99,6 @@ func (c *command) runWithError(ss []string) (bool, error) { sm := (map[string]struct{})(nil) - if args.FollowSitemapXML { - sm, err = newSitemapFetcher(client).Fetch(p.URL()) - - if err != nil { - return false, err - } - } - checker := newPageChecker( f, newLinkValidator(p.URL().Hostname(), rd, sm), diff --git a/command_test.go b/command_test.go index 1995f9f..19fc685 100644 --- a/command_test.go +++ b/command_test.go @@ -236,7 +236,7 @@ func TestCommandFailToRunWithJSONOutput(t *testing.T) { return nil, errors.New("foo") }, - ).Run([]string{"--json", "http://foo.com"}) + ).Run([]string{"--format=json", "http://foo.com"}) assert.False(t, ok) assert.Greater(t, b.Len(), 0) @@ -250,26 +250,12 @@ func TestCommandDoNotIncludeSuccessfulPageInJSONOutput(t *testing.T) { func(u *url.URL) (*fakeHttpResponse, error) { return newFakeHtmlResponse("", ""), nil }, - ).Run([]string{"--json", "http://foo.com"}) + ).Run([]string{"--format=json", "http://foo.com"}) assert.True(t, ok) assert.Equal(t, strings.TrimSpace(b.String()), "[]") } -func TestCommandIncludeSuccessfulPageInJSONOutputWhenRequested(t *testing.T) { - b := &bytes.Buffer{} - - ok := newTestCommandWithStdout( - b, - func(u *url.URL) (*fakeHttpResponse, error) { - return newFakeHtmlResponse("", ""), nil - }, - ).Run([]string{"--json", "--experimental-verbose-json", "http://foo.com"}) - - assert.True(t, ok) - assert.Equal(t, strings.TrimSpace(b.String()), "[{\"url\":\"\",\"links\":[]}]") -} - func TestCommandFailToRunWithJUnitOutput(t *testing.T) { b := &bytes.Buffer{} @@ -285,7 +271,7 @@ func TestCommandFailToRunWithJUnitOutput(t *testing.T) { return nil, errors.New("foo") }, - ).Run([]string{"--junit", "http://foo.com"}) + ).Run([]string{"--format=junit", "http://foo.com"}) assert.False(t, ok) assert.Greater(t, b.Len(), 0) @@ -295,7 +281,7 @@ func TestCommandFailWithVerboseAndJUnitOptions(t *testing.T) { b := &bytes.Buffer{} ok := newTestCommandWithStderr(b, nil).Run( - []string{"--junit", "--verbose", "http://foo.com"}, + []string{"--format=junit", "--verbose", "http://foo.com"}, ) assert.False(t, ok)