summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go52
1 files changed, 27 insertions, 25 deletions
diff --git a/main.go b/main.go
index 5c9534f..cfe7b3a 100644
--- a/main.go
+++ b/main.go
@@ -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.
//