diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 33 |
1 files changed, 11 insertions, 22 deletions
@@ -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 }, }, { |
