Skip to content

Commit

Permalink
Refactor (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe authored Jan 29, 2023
1 parent 988ce7a commit ee134be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions arguments.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type arguments struct {
FollowSitemapXML bool `long:"follow-sitemap-xml" description:"Scrape only pages listed in sitemap.xml"`
RawHeaders []string `long:"header" value-name:"<header>..." description:"Custom headers"`
IgnoreFragments bool `short:"f" long:"ignore-fragments" description:"Ignore URL fragments"`
JSONOutput bool `long:"json" description:"Output results in JSON"`
// TODO Integrate this option into --verbose in v3.
// TODO Merge text, JSON, and JUnit XML format options into --format.
JSONOutput bool `long:"json" description:"Output results in JSON"`
// TODO Integrate this option into --verbose.
VerboseJSON bool `long:"experimental-verbose-json" description:"Include successful results in JSON"`
JUnitOutput bool `long:"junit" description:"Output results as JUnit XML file"`
MaxRedirections int `short:"r" long:"max-redirections" value-name:"<count>" default:"64" description:"Maximum number of redirections"`
Expand Down
4 changes: 2 additions & 2 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func newCache() cache {
return cache{&sync.Map{}, &sync.Map{}}
}

func (c cache) LoadOrStore(key string) (interface{}, func(interface{})) {
func (c cache) LoadOrStore(key string) (any, func(any)) {
if x, ok := c.values.Load(key); ok {
return x, nil
}
Expand All @@ -26,7 +26,7 @@ func (c cache) LoadOrStore(key string) (interface{}, func(interface{})) {
return x, nil
}

return nil, func(x interface{}) {
return nil, func(x any) {
c.values.Store(key, x)
g.Done()
}
Expand Down
6 changes: 3 additions & 3 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (c *command) runWithError(ss []string) (bool, error) {
}

func (c *command) printResultsInJSON(rc <-chan *pageResult, verbose bool) (bool, error) {
rs := []interface{}{}
rs := []any{}
ok := true

for r := range rc {
Expand Down Expand Up @@ -194,13 +194,13 @@ func (c *command) printResultsInJUnitXML(rc <-chan *pageResult) (bool, error) {
return ok, nil
}

func (c *command) print(xs ...interface{}) {
func (c *command) print(xs ...any) {
if _, err := fmt.Fprintln(c.stdout, strings.TrimSpace(fmt.Sprint(xs...))); err != nil {
panic(err)
}
}

func (c *command) printError(xs ...interface{}) {
func (c *command) printError(xs ...any) {
s := fmt.Sprint(xs...)

// Do not check --color option here because this can be used on argument parsing errors.
Expand Down

0 comments on commit ee134be

Please sign in to comment.