From 317d4ba474733482492dc44385f4321456fde3e8 Mon Sep 17 00:00:00 2001 From: demo Date: Fri, 12 Jun 2026 11:15:46 -0400 Subject: refactor: streamline action-logic calling the "classic" crawler --- main.go | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/main.go b/main.go index f745ae4..512f75f 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ package main import ( "context" - "errors" "fmt" "log" "net/url" @@ -75,35 +74,25 @@ func main() { }, }, Action: func(ctx context.Context, cmd *cli.Command) error { - if shortcode := cmd.String("shortcode"); shortcode != "" { - rawURL, err := getURLFromShortcode(shortcodeFilename, shortcode) - if err != nil { - return err - } + var rawURL string + var err error - u, err := convertToURL(rawURL) + if shortcode := cmd.String("shortcode"); shortcode != "" { + rawURL, err = getURLFromShortcode(shortcodeFilename, shortcode) if err != nil { return err } - - classic(u, cmd.Int("concurrency"), cmd.Int("maxurls"), cmd.Int("depth")) - return nil + } else { + rawURL = cmd.String("url") } - if rawURL := cmd.String("url"); rawURL != "" { - u, err := convertToURL(rawURL) - if err != nil { - return err - } - - classic(u, cmd.Int("concurrency"), cmd.Int("maxurls"), cmd.Int("depth")) - return nil + u, err := convertToURL(rawURL) + if err != nil { + return err } - // We shouldn't reach this - // code, but let's at least - // document our intentions. - return errors.New("url and shortcode arguments should be mutually exclusive") + classic(u, cmd.Int("concurrency"), cmd.Int("maxurls"), cmd.Int("depth")) + return nil }, }, { -- cgit v1.2.3