summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-06-12 11:15:46 -0400
committerdemo <demo@antix1>2026-06-12 11:15:46 -0400
commit317d4ba474733482492dc44385f4321456fde3e8 (patch)
treefcfb4f7dbf9340a6c61e612d7cb60fe229e479c0
parent2d50328d3a6e901ff738242b5bff0852ae9b5903 (diff)
refactor: streamline action-logic calling the "classic" crawler
-rw-r--r--main.go33
1 files 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
},
},
{