diff options
| -rw-r--r-- | main.go | 52 |
1 files changed, 27 insertions, 25 deletions
@@ -73,31 +73,7 @@ func main() { DefaultText: "no limit", }, }, - Action: func(ctx context.Context, cmd *cli.Command) error { - rawURL := cmd.String("url") - - // If rawURL is empty, it - // means that we supplied - // --shortcode instead, so use - // that. - if rawURL == "" { - var err error - shortcode := cmd.String("shortcode") - - rawURL, err = getURLFromShortcode(shortcodeFilename, shortcode) - if err != nil { - return err - } - } - - u, err := convertToURL(rawURL) - if err != nil { - return err - } - - classic(u, cmd.Int("concurrency"), cmd.Int("maxurls"), cmd.Int("depth")) - return nil - }, + Action: run, }, { Name: "shortcode", @@ -116,6 +92,32 @@ func main() { } } +func run(ctx context.Context, cmd *cli.Command) error { + rawURL := cmd.String("url") + + // If rawURL is empty, it + // means that we supplied + // --shortcode instead, so use + // that. + if rawURL == "" { + var err error + shortcode := cmd.String("shortcode") + + rawURL, err = getURLFromShortcode(shortcodeFilename, shortcode) + if err != nil { + return err + } + } + + u, err := convertToURL(rawURL) + if err != nil { + return err + } + + classic(u, cmd.Int("concurrency"), cmd.Int("maxurls"), cmd.Int("depth")) + return nil +} + // convertToURL parses the given rawURL into a [url.URL]. If the // rawURL is missing a scheme, "https://" is prepended before parsing. // |
